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: Build data.
  
  Maybe download the appropriate data.
  
  :return (bpe_data, json_path):
      bpe_data and path to encoder json
docstr_tok: ["Build","data",".","Maybe","download","the","appropriate","data",".",":","return","(","bpe_data",",","json_path",")",":","bpe_data","and","path","to","encoder","json"]
code: def _build_data(self) -> Tuple[str, str]:
      """
      Build data.
  
      Maybe download the appropriate data.
  
      :return (bpe_data, json_path):
          bpe_data and path to encoder json
      """
      data_path = os.path.join(self.opt["datapath"], "gpt2")
      vocab_path = os.path.join(data_path, "vocab.bpe")
      json_path = os.path.join(data_path, "encoder.json")
      if not PathManager.exists(vocab_path) or not PathManager.exists(
          json_path
      ):
          make_dir(data_path)
          download(self.DEFAULT_VOCAB_BPE, data_path, "vocab.bpe")
          download(self.DEFAULT_ENCODER_JSON, data_path, "encoder.json")
      with PathManager.open(vocab_path, "r", encoding="utf-8") as f:
          bpe_data = f.read()
  
      return bpe_data, json_path, vocab_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 2 for calling the Gpt2BpeHelper obj's underlying member method code with example usage: obj._build_data() and returns: bpe_data,  json_path,  vocab_path