code: def mock_vocabulary(encode_dict, vocab_size=None):
      vocab = absltest.mock.MagicMock()
      vocab.vocab_size = vocab_size
      idx_to_str = {v: k for k, v in encode_dict.items()}
      vocab.decode = absltest.mock.MagicMock(
          side_effect=lambda ids: [idx_to_str[id] for id in ids]
      )
      return vocab
  
file_path: mesh/mesh_tensorflow/transformer/utils_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import absltest
  from absl.testing import parameterized
  import mesh_tensorflow
  from mesh_tensorflow.transformer import utils
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 1 for calling a global function with example usage: mock_vocabulary(encode_dict, vocab_size) and returns: vocab