In the context of nn Modules, the “to” method is explained in the documentation here 144.
The move happens to only parameters and buffers. Hence, moving a loss function like CrossEntropy to GPU doesn’t change anything. In a custom Loss function made subclassing nn.Module, the “.to()” will be inherited and will move any parameters/buffers to the gpu.
The custom loss function you made may not have subclassed nn.Module and hence, did not have the “.to()”  method.