class_docstr: Apply layer normalization to the n-dimensional input tensor:
  
  .. math::
     out = gamma * (input - E[x]) / sqrt(Var[x] + epsilon) + beta
  
  
  Parameters
  ----------
  x: tensor<\*?, T> (Required)
      * Input tensor.
  
  axes: const<[K], i32> (Optional)
      * Dimensions to perform layer normalization.
      * Default is ``None`` (all dimensions).
  
  gamma: const tensor<\*?, T>, T> (Optional)
      * if provided, the shape must be be ``x.shape[axes]``. For instance, if
        input ``x`` with shape ``(3,4,5,6)`` and ``axes = [2,3]``, gamma must have
        shape ``(5,6)``.
      * Default is all ones.
  
  beta: const tensor<\*?, T>, T> (Optional)
      * Same shape as gamma.
      * Default is all zeros.
  
  epsilon: const T (Optional)
      * Small constant to avoid division by ``0``.
      * Default is ``1e-5``.
  
  
  Returns
  -------
  tensor<\*?, T>:
   * Tensor with same shape and type as the input tensor ``x``.
  
  Attributes
  ----------
  T: fp16, fp32
class_docstr_tok: ["Apply","layer","normalization","to","the","n-dimensional","input","tensor",":","..","math",":",":","out","=","gamma","*","(","input","-","E","[","x","]",")","\/","sqrt","(","Var","[","x","]","+","epsilon",")","+","beta","Parameters","--","--","--","--","--","x",":","tensor","<","\\","*","?",",","T",">","(","Required",")","*","Input","tensor",".","axes",":","const","<","[","K","]",",","i32",">","(","Optional",")","*","Dimensions","to","perform","layer","normalization",".","*","Default","is","``","None","``","(","all","dimensions",")",".","gamma",":","const","tensor","<","\\","*","?",",","T",">",",","T",">","(","Optional",")","*","if","provided",",","the","shape","must","be","be","``","x.shape","[","axes","]","``",".","For","instance",",","if","input","``","x","``","with","shape","``","(","3,4,5,6",")","``","and","``","axes","=","[","2,3","]","``",",","gamma","must","have","shape","``","(","5,6",")","``",".","*","Default","is","all","ones",".","beta",":","const","tensor","<","\\","*","?",",","T",">",",","T",">","(","Optional",")","*","Same","shape","as","gamma",".","*","Default","is","all","zeros",".","epsilon",":","const","T","(","Optional",")","*","Small","constant","to","avoid","division","by","``","0","``",".","*","Default","is","``","1e-5","``",".","Returns","--","--","--","-","tensor","<","\\","*","?",",","T",">",":","*","Tensor","with","same","shape","and","type","as","the","input","tensor","``","x","``",".","Attributes","--","--","--","--","--","T",":","fp16",",","fp32"]
code: def type_inference(self):
      rank = self.x.rank
  
      # check valid axes
      positive_axes = [
          axis + rank if axis < 0 else axis for axis in self.axes.val
      ]
      if not all([axis >= 0 and axis < rank for axis in positive_axes]):
          raise ValueError(
              "axes must in the range of [-x.rank, x.rank-1]."
          )
  
      # check shape of gamma and beta
      normalized_shape = [
          self.x.shape[i] for i in range(rank) if i in positive_axes
      ]
      if (
          self.gamma is not None
          and not layer_norm._is_compatible_shape(
              list(self.gamma.shape), normalized_shape
          )
      ):
          raise ValueError(
              "Expect shape {} for gamma, but get shape {} instead".format(
                  normalized_shape, self.gamma.shape
              )
          )
  
      if self.beta is not None and not layer_norm._is_compatible_shape(
          list(self.gamma.shape), normalized_shape
      ):
          raise ValueError(
              "Expect shape {} for beta, but get shape {} instead".format(
                  normalized_shape, self.beta.shape
              )
          )
  
      x_shape = self.x.shape
      return types.tensor(self.x.dtype, tuple(x_shape))
  
imports: import numpy
  from coremltools.converters.mil.mil import DefaultInputs, InputSpec, Operation, TensorInputType, precondition, types
  from coremltools.converters.mil.mil.operation import VALUE
  from coremltools.converters.mil.mil.ops.defs._op_reqs import register_op
  from coremltools.converters.mil.mil.types.symbolic import any_symbolic
label_desc: Use image node_id 3 for calling the layer_norm obj's underlying member method code with example usage: obj.type_inference() and returns: types