docstr: Instantiate tokenizer.
docstr_tok: ["Instantiate","tokenizer","."]
code: def get_tokenizer(self, opt):
      """
      Instantiate tokenizer.
      """
      if opt.get("model_name"):
          fle_key = opt["model_name"]
      else:
          model_sz = opt["gpt2_size"]
          if model_sz == "small":
              model_key = "gpt2"
          elif model_sz == "distilgpt2":
              model_key = "distilgpt2"
          else:
              model_key = f"gpt2-{model_sz}"
          # check if datapath has the files that hugging face code looks for
          hf_dir = os.path.join(opt["datapath"], "hf", model_key)
          if all(
              PathManager.exists(os.path.join(hf_dir, file_name))
              for file_name in ["merges.txt", "vocab.json"]
          ):
              fle_key = PathManager.get_local_path(
                  hf_dir, recursive=True
              )
  
          else:
              fle_key = model_key
      return GPT2Tokenizer.from_pretrained(fle_key)
  
imports: import os
  import re
  from abc import ABC, abstractmethod, abstractproperty
  from collections import defaultdict
  from typing import List
  from parlai.core.dict import DictionaryAgent
  from parlai.core.opt import Opt
  from parlai.utils.io import PathManager
label_desc: Use image node_id 3 for calling the Gpt2DictionaryAgent obj's underlying member method code with example usage: obj.get_tokenizer(opt) and returns: GPT2Tokenizer