code: def test_ids_to_embedding_correctlyEmbeds(self):
      seq_len = 5
      vocab_size = 5
      model_size = 2
      gate_embedding_size = 1
      frequent_token_fraction = 0.4
  
      vocab_dim = mtf.Dimension("vocab", vocab_size)
      model_dim = mtf.Dimension("model", model_size)
      length_dim = mtf.Dimension("length", seq_len)
  
      context = mock.MagicMock()
      context.train = False
  
      ids = tf.constant([0, 1, 2, 3, 4], dtype=tf.int32)
      mtf_ids = mtf.import_tf_tensor(
          self.mesh, ids, shape=mtf.Shape([length_dim])
      )
  
      self.initializer_mock.side_effect = initialize_by_shape(
          {
              # Embedding weights.
              (5, 2): list(range(10)),
              # Context weights.
              (4, 2, 2): list(range(16)),
              # Prior weights.
              (3, 1, 2): list(range(6)),
              # Prior vocab vector.
              (2, 1): list(range(2)),
              # Prior gates vector.
              (3, 2): list(range(6)),
              # Prior bias.
              (2, 3): list(range(6)),
          }
      )
  
      vocab_embedding = vocab_embeddings.Mixtape(
          self.mesh,
          vocab_dim,
          output_dim=model_dim,
          variable_dtype=self.variable_dtype,
          name="embedding",
          ensemble_dim=None,
          gate_embedding_size=gate_embedding_size,
          frequent_token_fraction=frequent_token_fraction,
      )
  
      mtf_embedding = vocab_embedding.ids_to_embedding(
          mtf_ids, context=None
      )
  
      mesh_impl = mtf.placement_mesh_impl.PlacementMeshImpl(
          shape=[], layout={}, devices=[""]
      )
      lowering = mtf.Lowering(self.graph, {self.mesh: mesh_impl})
      actual_embedding = lowering.export_to_tf_tensor(mtf_embedding)
  
      self.evaluate(tf.global_variables_initializer())
      self.evaluate(lowering.copy_masters_to_slices())
      actual = self.evaluate([actual_embedding])[0]
  
      self.assertAllClose(actual, np.reshape(list(range(10)), (5, 2)))
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import mesh_tensorflow
  from mesh_tensorflow.transformer import vocab_embeddings
  import mock
  import numpy
  import scipy.special
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the MixtapeTest obj's underlying member method code with example usage: obj.test_ids_to_embedding_correctlyEmbeds() without return types