code: def layer_norm(input_tensor, name=None):
      with tf.compat.v1.variable_scope(
          name, "LayerNorm", [input_tensor]
      ) as sc:
          inputs_shape = input_tensor.shape
          inputs_rank = inputs_shape.ndims
  
          dtype = input_tensor.dtype.base_dtype
          begin_norm_axis = inputs_rank - 1
  
          params_shape = inputs_shape[-1:]
  
          # Allocate parameters for the beta and gamma of the normalization.
          beta = tf.compat.v1.get_variable(
              "beta",
              shape=params_shape,
              dtype=dtype,
              initializer=tf.zeros_initializer(),
              trainable=True,
          )
          gamma = tf.compat.v1.get_variable(
              "gamma",
              shape=params_shape,
              dtype=dtype,
              initializer=tf.ones_initializer(),
              trainable=True,
          )
          # Calculate the moments on the last axis (layer activations).
          norm_axes = list(range(begin_norm_axis, inputs_rank))
          mean, variance = tf.nn.moments(
              input_tensor, norm_axes, keepdims=True
          )
          # Compute layer normalization using the batch_normalization function.
          variance_epsilon = 1e-12 if dtype != tf.float16 else 1e-3
          outputs = tf.nn.batch_normalization(
              input_tensor,
              mean,
              variance,
              offset=beta,
              scale=gamma,
              variance_epsilon=variance_epsilon,
          )
          outputs.set_shape(inputs_shape)
      return outputs
  
imports: import copy
  import json
  import math
  import numpy
  import tensorflow
  import functools
  from transformers.activations_tf import gelu
  from finetune.optimizers.recompute_grads import recompute_grad
  from finetune.nn.auxiliary import embed_position
label_desc: Use image node_id 4 for calling a global function with example usage: layer_norm(input_tensor, name) and returns: outputs