code: def convert_vocab(args):
      print("converting vocab")
      merges_path = os.path.join(args.tf_model_path, "vocab.bpe")
      vocab_path = os.path.join(args.tf_model_path, "encoder.json")
      gluon_merges_path = os.path.join(args.save_dir, "gpt2.merges")
      gluon_vocab_path = os.path.join(args.save_dir, "gpt2.vocab")
  
      shutil.copy(merges_path, gluon_merges_path)
      with open(vocab_path, "r", encoding="utf-8") as f_v:
          tf_vocab = json.load(f_v)
      tf_vocab = list(tf_vocab.items())
      tf_vocab = sorted(tf_vocab, key=lambda x: x[1])
      all_tokens = [e[0] for e in tf_vocab]
      eos_token = all_tokens[-1]
      assert eos_token == "<|endoftext|>"
      gluon_vocab = Vocab(
          all_tokens, unk_token=None, eos_token=eos_token
      )
      gluon_vocab.save(gluon_vocab_path)
  
      vocab_size = len(gluon_vocab)
      print("| converted dictionary: {} types".format(vocab_size))
      return vocab_size
  
imports: import os
  import re
  import json
  import shutil
  import logging
  import argparse
  import tensorflow
  from tensorflow.contrib.training import HParams
  from gpt_2.src import model
  import mxnet
  import numpy
  from numpy.testing import assert_allclose
  from gluonnlp.data.vocab import Vocab
  from gluonnlp.utils.misc import sha1sum, logging_config, naming_convention
  from gluonnlp.models.gpt2 import GPT2Model, GPT2ForLM
label_desc: Use image node_id 2 for calling a global function with example usage: convert_vocab(args) and returns: vocab_size