Memory Leak When Replacing torch.nn.NLLLoss() with torch.nn.CrossEntropyLoss()

Could you post a small code snippet which would reproduce the memory leak?
Tensors should be freed once all references to them are deleted.
If an object still points to the tensor, it cannot be freed, but I’m unsure what your exact use case is.