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: Implements BPE dropout (Provlikov et al., 2019).
  
  https://arxiv.org/abs/1910.13267
  
  Randomly removes merges from the list of possible merges. This can
  result in different subwords being used to realized the same string,
  and effectively regularizes representations.
docstr_tok: ["Implements","BPE","dropout","(","Provlikov","et","al.",",","2019",")",".","https",":","\/\/arxiv.org\/abs\/1910.13267","Randomly","removes","merges","from","the","list","of","possible","merges",".","This","can","result","in","different","subwords","being","used","to","realized","the","same","string",",","and","effectively","regularizes","representations","."]
code: def _dropout_pairs(self, pairs):
      """
      Implements BPE dropout (Provlikov et al., 2019).
  
      https://arxiv.org/abs/1910.13267
  
      Randomly removes merges from the list of possible merges. This can
      result in different subwords being used to realized the same string,
      and effectively regularizes representations.
      """
      if not self.bpe_dropout or not self._bpe_dropout_enabled:
          return pairs
  
      dropped_pairs = [
          p for p in pairs if random.random() > self.bpe_dropout
      ]
      if not dropped_pairs:
          dropped_pairs = [random.choice(pairs)]
      return dropped_pairs
  
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 6 for calling the Gpt2BpeHelper obj's underlying member method code with example usage: obj._dropout_pairs(pairs) and returns: dropped_pairs, pairs