code: def __init__(self, encoder, bpe_merges, errors="replace"):
      self.encoder = encoder
      self.decoder = {v: k for k, v in self.encoder.items()}
      self.errors = errors  # how to handle errors in decoding
      self.byte_encoder = bytes_to_unicode()
      self.byte_decoder = {v: k for k, v in self.byte_encoder.items()}
      self.bpe_ranks = dict(zip(bpe_merges, range(len(bpe_merges))))
      self.cache = {}
  
      # Should haved added re.IGNORECASE so BPE merges can happen for capitalized versions of contractions
      self.pat = re.compile(
          r"""'s|'t|'re|'ve|'m|'ll|'d| ?\p{L}+| ?\p{N}+| ?[^\s\p{L}\p{N}]+|\s+(?!\S)|\s+"""
      )
  
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 1 to create a new Encoder object  with example: obj = Encoder(encoder, bpe_merges, errors)