code: def get_embedding(
      hparams=None,
      init_value=None,
      num_embeds=None,
      variable_scope="Embedding",
  ):
      r"""Creates embedding variable if not exists.
  
      Args:
          hparams (dict or HParams, optional): Embedding hyperparameters. Missing
              hyperparameters are set to default values. See
              :func:`~texar.tf.modules.default_embedding_hparams`
              for all hyperparameters and default values.
  
              If :attr:`init_value` is given, :attr:`hparams["initializer"]`,
              and :attr:`hparams["dim"]` are ignored.
          init_value (Tensor or numpy array, optional): Initial values of the
              embedding variable. If not given, embedding is initialized as
              specified in :attr:`hparams["initializer"]`.
          num_embeds (int, optional): The number of embedding items
              (e.g., vocabulary size). Required if :attr:`init_value` is
              not provided.
          variable_scope (str or VariableScope, optional): Variable scope of
              the embedding variable.
  
      Returns:
          Variable or Tensor: A 2D `Variable` or `Tensor` of the same shape with
          :attr:`init_value` or of the shape ``[num_embeds, hparams["dim"]]``.
      """
      with tf.variable_scope(variable_scope):
          if hparams is None or isinstance(hparams, dict):
              hparams = HParams(hparams, default_embedding_hparams())
          regularizer = layers.get_regularizer(hparams["regularizer"])
          if init_value is None:
              initializer = layers.get_initializer(
                  hparams["initializer"]
              )
              dim = hparams["dim"]
              if not isinstance(hparams["dim"], (list, tuple)):
                  dim = [dim]
              embedding = tf.get_variable(
                  name="w",
                  shape=[num_embeds] + dim,
                  initializer=initializer,
                  regularizer=regularizer,
                  trainable=hparams["trainable"],
              )
          else:
              init_value = tf.cast(init_value, tf.float32)
              embedding = tf.get_variable(
                  name="w",
                  initializer=init_value,
                  regularizer=regularizer,
                  trainable=hparams["trainable"],
              )
  
          return embedding
  
imports: import tensorflow
  from texar.tf.hyperparams import HParams
  from texar.tf.core import layers
label_desc: Use image node_id 2 for calling a global function with example usage: get_embedding(hparams, init_value, num_embeds, variable_scope) and returns: embedding