When I use gather in forward,I get this error:
RuntimeError: save_for_backward can only save input or output tensors,
 but argument 0 doesn't satisfy this condition

It seems code below is not correct
        inds=inds.view(N,C,-1).data
        out=torch.gather(target,dim=2,index=inds)

After searching here, I foud this one-----Nn module using index_select to the answer there,I changed the code.
        inds=inds.view(N,C,-1)
        out=torch.gather(target,dim=2,index=inds)

But then I get another eror-------AssertionError: Gather can’t differentiate the index.Could anyone tell me why?Thanks a lot.