The code looks generally alright. Some minor points:

Don’t use torch.FloatTensor, but the factory methods (e.g. torch.empty(...).normal_(), torch.randn(...) etc.)
I’m unsure about the logic to sum the loss in dim0 and calculating the mean afterwards, but assume it fits your use case (in e.g. weighted nn.CrossEntropyLoss you would normalize with the weights if reduction='mean' is used)