class_docstr: A mapping from indices to vocab elements.
class_docstr_tok: ["A","mapping","from","indices","to","vocab","elements","."]
docstr: Replace tokens in vocab with given replacement.
  Used for replacing special strings for special tokens.
  e.g. '[UNK]' for UNK
docstr_tok: ["Replace","tokens","in","vocab","with","given","replacement",".","Used","for","replacing","special","strings","for","special","tokens",".","e.g",".","'","[","UNK","]","'","for","UNK"]
code: def replace_tokens(self, replacements):
      """Replace tokens in vocab with given replacement.
      Used for replacing special strings for special tokens.
      e.g. '[UNK]' for UNK"""
      for token, replacement in replacements.items():
          idx = self.idx.pop(token, len(self._vocab))
          if idx == len(self._vocab):
              self._vocab.append(replacement)
              self.counts.append(1)
          else:
              self._vocab[idx] = replacement
          self.idx[replacement] = idx
  
imports: import itertools
  from collections import Counter
  from typing import Dict, List, Optional, Tuple
  import torch
  from pytext.common.constants import SpecialTokens, Token
  from pytext.utils import cuda, precision
label_desc: Use image node_id 2 for calling the Vocabulary obj's underlying member method code with example usage: obj.replace_tokens(replacements) without return types