Yes, this behavior should be correct.


It seems you might be thinking about a static graph definition, was was used e.g. in Theano. In PyTorch you don’t define b as a “method” on a, but instead calculate it dynamically in the forward pass.