class_docstr: Applies `Layer Normalization <https://arxiv.org/abs/1607.06450>`_ over a input tensor
  
  Args:
      normalized_shape (int or list or torch.Size): input shape from an expected input
          of size
  
          .. math::
              [* \times \text{normalized\_shape}[0] \times \text{normalized\_shape}[1]
                  \times \ldots \times \text{normalized\_shape}[-1]]
  
          If a single integer is used, it is treated as a singleton list, and this module will
          normalize over the last dimension which is expected to be of that specific size.
      eps (Optional, float): Value added to the denominator for numerical stability. Default: 1e-5
      elementwise_affine (bool): If ``True``, use learnable affine parameters. Default: ``True``
  
  Shape:
      - Input: :math:`(N, *)` where :math:`N` is the batch size
      - Output: same shape as the input
code: def forward(self, x: Tensor) -> Tensor:
      n_dim = x.ndim
      if (
          x.shape[1] == self.normalized_shape[0] and n_dim > 2
      ):  # channel-first format
          s, u = torch.std_mean(x, dim=1, keepdim=True, unbiased=False)
          x = (x - u) / (s + self.eps)
          if self.weight is not None:
              # Using fused operation for performing affine transformation: x = (x * weight) + bias
              n_dim = x.ndim - 2
              new_shape = [1, self.normalized_shape[0]] + [1] * n_dim
              x = torch.addcmul(
                  input=self.bias.reshape(*[new_shape]),
                  value=1.0,
                  tensor1=x,
                  tensor2=self.weight.reshape(*[new_shape]),
              )
          return x
      elif (
          x.shape[-1] == self.normalized_shape[0]
      ):  # channel-last format
          return super().forward(x)
      else:
          raise NotImplementedError(
              "LayerNorm is supported for channel-first and channel-last format only"
          )
  
file_path: ml-cvnets/cvnets/layers/normalization/layer_norm.py
imports: from typing import List, Optional, Union
  import torch
  from torch import Size, Tensor, nn
  from cvnets.layers.normalization import register_norm_fn
label_desc: Use image node_id 2 for calling the LayerNorm obj's underlying member method code with example usage: obj.forward(x) and returns: x, super