code: def one_hot_to_embedding(one_hot, embedding_size=None):
      """Gets a dense embedding vector from a one-hot encoding."""
      num_tokens = int(one_hot.shape[1])
      label_id = tf.argmax(one_hot, axis=1)
      if embedding_size is None:
          embedding_size = get_default_embedding_size(num_tokens)
      embedding = tf.get_variable(
          "one_hot_embedding",
          [num_tokens, embedding_size],
          dtype=tf.float32,
      )
      return tf.nn.embedding_lookup(
          embedding, label_id, name="token_to_embedding"
      )
  
file_path: magenta/magenta/models/gansynth/lib/util.py
imports: import io
  import os
  from absl import logging
  import numpy
  import tensorflow.compat.v1
  import tf_slim
label_desc: Use image node_id 2 for calling a global function with example usage: one_hot_to_embedding(one_hot, embedding_size) and returns: tf