add index and count to list (#17446)
Summary:
see https://github.com/pytorch/pytorch/issues/16662
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17446
Differential Revision: D14461293
Pulled By: Krovatkin
fbshipit-source-id: 03572467cdf85efc909c1864c0558a93085c8ff3