I don’t think you need the nested loop, which will slow down your code.
This should also work:
inputTensor = torch.randn(10, 10)
outputTensor = inputTensor.clone()
for n in range(inputTensor.size(0)):
    for m in range(inputTensor.size(1)):
        outputTensor[n][m] = torch.div(inputTensor[n][m], torch.sum(inputTensor[n]))

# without the loop
x = inputTensor.clone()
x = x / x.sum(1, keepdims=True)

print((x == outputTensor).all())
> True