code: def get_encoder(gpt2_pretrained_path):
      with open(
          os.path.join(gpt2_pretrained_path, "encoder.json"), "r"
      ) as f:
          encoder = json.load(f)
      with open(
          os.path.join(gpt2_pretrained_path, "vocab.bpe"),
          "r",
          encoding="utf-8",
      ) as f:
          bpe_data = f.read()
      bpe_merges = [
          tuple(merge_str.split())
          for merge_str in bpe_data.split("\n")[1:-1]
      ]
      return Encoder(
          encoder=encoder,
          bpe_merges=bpe_merges,
      )
  
file_path: texar/examples/gpt-2/utils/processor.py
imports: import os
  import json
  import regex
  from functools import lru_cache
label_desc: Use image node_id 3 for calling a global function with example usage: get_encoder(gpt2_pretrained_path) and returns: Encoder