code: def var_random(name, shape, regularizable=False):
      """
      Initialize a random variable using xavier initialization.
      Add regularization if regularizable=True
      :param name:
      :param shape:
      :param regularizable:
      :return:
      """
      v = tf.compat.v1.get_variable(
          name,
          shape=shape,
          initializer=tf.compat.v1.keras.initializers.VarianceScaling(
              scale=1.0, mode="fan_avg", distribution="uniform"
          ),
      )
      if regularizable:
          with tf.compat.v1.name_scope(name + "/Regularizer/"):
              tf.compat.v1.add_to_collection(
                  tf.compat.v1.GraphKeys.REGULARIZATION_LOSSES,
                  tf.nn.l2_loss(v),
              )
      return v
  
file_path: attention-ocr/aocr/model/cnn.py
imports: from __future__ import absolute_import
  import numpy
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: var_random(name, shape, regularizable) and returns: v