Add flatten for named tensors. (#25672)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/25672
There are three overloads:
1) flatten(tensor, int start_dim, int end_dim, Dimname out_dim)
2) flatten(tensor, Dimname start_dim, Dimname end_dim, Dimname out_dim)
3) flatten(tensor, DimnameList dims, Dimname out_dim)
`flatten` joins all the dimensions between start_dim and end_dim into
one dimension. The name of the output dimension is specified by
`out_dim`.
In the case where flatten takes a list of `dims` to flatten, all the
dimensions in `dims` must be in consecutive order.
Test Plan: - new tests [namedtensor ci]
Differential Revision: D17192656
Pulled By: zou3519
fbshipit-source-id: 55d2b23358bd77cbef299f66701a8da8cd194f4f