Doubt about a loss function

Can anyone help me out with how I can write a loss function to spread the output tensors of a network uniformly ? Let’s say my network gives a tensor [[x1] , [x2] , [x3] , …[xn]] . I want to spread these points evenly between 0 to 1 . How can i achieve this ?

P.S. I am sorry because I think this question is more suitable for Stack Overflow but I like the pytorch community here much better. So, I am asking this here.

Assuming you want the distribution to be uniform, it sounds like you might want something like KL Divergence loss:
KLDivLoss — PyTorch 1.9.0 documentation