I saw some code in a repo that was using torch.normal() with a possibly negative standard deviation. I thought the code was wrong and that torch.normal() would surely give an error with a negative standard deviation, but when I tried it, it just worked with the resulting sample being positive…

  
      pytorch.org
  
  
    

torch.normal — PyTorch 1.7.0 documentation 4



  
  
    
    
  
  


I had trouble finding the exact implementation in the pytorch library so I was unable to see the actual code to see what it is doing, it seems like it just takes the absolute value, but I am not sure. How does this work?