F.batch_norm give nan value

Hi! Could someone please help me with the following code? I can’t figure out why I’m getting nan values in my batch normalization (I found it with autograd anomaly detection)

def ConvolutionBlock_F(x : torch.Tensor, 
  weight : torch.Tensor, bias : torch.Tensor) -> torch.Tensor:
  # input dimension: (number of images, channels, height, width)
  x = F.conv2d(x, weight, bias, stride=1, padding='same')
  x = F.batch_norm(x, None, None, training=True) 
  x = F.relu(x)
  return x

The error message is:
Function ‘NativeBatchNormBackwardBackward0’ returned nan values in its 0th output.