Hello @ronghui,
From the document,

Expand this tensor to the same size as  other .  self.expand_as(other)  is equivalent to  self.expand(other.size()) .

And the .expand() operation involves some broadcasting semantics here 1.0k. I think you could not “expand” a large size tensor to a smaller one. So the code snippet above will not work.
If I am wrong, please correct me. Thanks.