code: def load_ngram_mappings(
      input_name: str, max_misspelled_freq: int = 1000000000
  ) -> Tuple[defaultdict, Set]:
      """Loads n-gram mapping vocabularies in form required by dynamic programming
      Args:
          input_name: file with n-gram mappings
          max_misspelled_freq: threshold on misspelled n-gram frequency
      Returns:
          vocab: dict {key=original_ngram, value=dict{key=misspelled_ngram, value=frequency}}
          ban_ngram: set of banned misspelled n-grams
  
      Input format:
          u t o	u+i t o	49	8145	114
          u t o	<DELETE> t e	63	8145	16970
          u t o	o+_ t o	42	8145	1807
      """
      vocab = defaultdict(dict)
      ban_ngram = set()
  
      with open(input_name, "r", encoding="utf-8") as f:
          for line in f:
              (
                  orig,
                  misspelled,
                  joint_freq,
                  orig_freq,
                  misspelled_freq,
              ) = line.strip().split("\t")
              if orig == "" or misspelled == "":
                  raise ValueError(
                      "Empty n-gram: orig="
                      + orig
                      + "; misspelled="
                      + misspelled
                  )
              misspelled = misspelled.replace("<DELETE>", "=")
              if (
                  misspelled.replace("=", "").strip() == ""
              ):  # skip if resulting ngram doesn't contain any real character
                  continue
              if int(misspelled_freq) > max_misspelled_freq:
                  ban_ngram.add(
                      misspelled + " "
                  )  # space at the end is required within get_index function
              vocab[orig][misspelled] = int(joint_freq) / int(orig_freq)
      return vocab, ban_ngram
  
imports: import json
  import math
  import random
  import re
  from collections import defaultdict, namedtuple
  from typing import Dict, List, Set, Tuple, Union
  import numpy
  from numba import jit
label_desc: Use image node_id 2 for calling a global function with example usage: load_ngram_mappings(input_name, max_misspelled_freq) and returns: vocab,  ban_ngram