class_docstr: BPE Helper for GPT2 Models.
  
  Original source:
      https://github.com/openai/gpt-2/blob/main/src/encoder.py
  
  Original license: MIT
  
  This is a modified implementation from that of fairseq:
      https://github.com/pytorch/fairseq/blob/main/fairseq/data/encoders/gpt2_bpe_utils.py
  
  Fairseq license: MIT
class_docstr_tok: ["BPE","Helper","for","GPT2","Models",".","Original","source",":","https",":","\/\/github.com\/openai\/gpt-2\/blob\/main\/src\/encoder.py","Original","license",":","MIT","This","is","a","modified","implementation","from","that","of","fairseq",":","https",":","\/\/github.com\/pytorch\/fairseq\/blob\/main\/fairseq\/data\/encoders\/gpt2_bpe_utils.py","Fairseq","license",":","MIT"]
docstr: Save appropriate files.
  
  :param dir_name:
      directory to save.
  :param file_name:
      file to save.
docstr_tok: ["Save","appropriate","files",".",":","param","dir_name",":","directory","to","save",".",":","param","file_name",":","file","to","save","."]
code: def save(self, dir_name: str, file_name: str):
      """
      Save appropriate files.
  
      :param dir_name:
          directory to save.
      :param file_name:
          file to save.
      """
      out_json_path = os.path.join(dir_name, file_name + "-vocab.json")
      out_merge_path = os.path.join(dir_name, file_name + "-merges.txt")
      # Possibly bad assumption: if the destination file already exists,
      # we don't need to copy it over again.
      if not PathManager.exists(out_json_path):
          logging.info(f"Copying {self.json_path} to {out_json_path}")
          PathManager.copy(self.json_path, out_json_path)
      if not PathManager.exists(out_merge_path):
          logging.info(f"Copying {self.merge_path} to {out_merge_path}")
          PathManager.copy(self.merge_path, out_merge_path)
  
imports: from parlai.core.params import ParlaiParser
  from abc import ABC, abstractmethod
  from functools import lru_cache
  import json
  import os
  import random
  import re
  from typing import Dict, List, Optional, Set, Tuple
  from typing_extensions import final
  from parlai.core.build_data import download, make_dir
  from parlai.core.opt import Opt
  from parlai.utils.misc import warn_once
  from parlai.utils.typing import TShared
  from parlai.utils.io import PathManager
  import parlai.utils.logging
label_desc: Use image node_id 11 for calling the Gpt2BpeHelper obj's underlying member method code with example usage: obj.save(dir_name, file_name) without return types