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: Returns list of utf-8 byte and a corresponding list of unicode strings.
  
  The reversible bpe codes work on unicode strings. This means you need a large #
  of unicode characters in your vocab if you want to avoid UNKs. When you're at
  something like a 10B token dataset you end up needing around 5K for decent
  coverage. This is a significant percentage of your normal, say, 32K bpe vocab.
  To avoid that, we want lookup tables between utf-8 bytes and unicode strings.
  And avoids mapping to whitespace/control characters the bpe code barfs on.
docstr_tok: ["Returns","list","of","utf-8","byte","and","a","corresponding","list","of","unicode","strings",".","The","reversible","bpe","codes","work","on","unicode","strings",".","This","means","you","need","a","large","#","of","unicode","characters","in","your","vocab","if","you","want","to","avoid","UNKs",".","When","you","'re","at","something","like","a","10B","token","dataset","you","end","up","needing","around","5K","for","decent","coverage",".","This","is","a","significant","percentage","of","your","normal",",","say",",","32K","bpe","vocab",".","To","avoid","that",",","we","want","lookup","tables","between","utf-8","bytes","and","unicode","strings",".","And","avoids","mapping","to","whitespace\/control","characters","the","bpe","code","barfs","on","."]
code: def bytes_to_unicode(self) -> Dict[int, str]:
      """
      Returns list of utf-8 byte and a corresponding list of unicode strings.
  
      The reversible bpe codes work on unicode strings. This means you need a large #
      of unicode characters in your vocab if you want to avoid UNKs. When you're at
      something like a 10B token dataset you end up needing around 5K for decent
      coverage. This is a significant percentage of your normal, say, 32K bpe vocab.
      To avoid that, we want lookup tables between utf-8 bytes and unicode strings.
      And avoids mapping to whitespace/control characters the bpe code barfs on.
      """
      bs: List[int] = (
          list(range(ord("!"), ord("~") + 1))
          + list(range(ord("¡"), ord("¬") + 1))
          + list(range(ord("®"), ord("ÿ") + 1))
      )
      cs: List[int] = bs[:]
      n = 0
      for b in range(2**8):
          if b not in bs:
              bs.append(b)
              cs.append(2**8 + n)
              n += 1
      str_cs: List[str] = [chr(n) for n in cs]
      return dict(zip(bs, str_cs))
  
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 4 for calling the Gpt2BpeHelper obj's underlying member method code with example usage: obj.bytes_to_unicode() and returns: dict