code: def load_trie(infile):
      with open(infile, "r", encoding="utf8") as fin:
          line = fin.readline().strip()
          flags = [x == "T" for x in line.split()]
          if len(flags) != len(Trie.ATTRS) + 1:
              raise ValueError("Wrong file format")
          nodes_number, root = map(int, fin.readline().strip().split())
          alphabet = fin.readline().strip().split()
          trie = Trie(alphabet)
          for i, attr in enumerate(Trie.ATTRS):
              setattr(trie, attr, flags[i])
          read_data = flags[-1]
          final = [False] * nodes_number
          # print(len(alphabet), nodes_number)
          if trie.dict_storage:
              graph = [
                  defaultdict(lambda: -1) for _ in range(nodes_number)
              ]
          elif trie.is_numpied:
              final = np.array(final)
              graph = np.full(
                  shape=(nodes_number, len(alphabet)),
                  fill_value=Trie.NO_NODE,
                  dtype=int,
              )
          else:
              graph = [
                  [Trie.NO_NODE for a in alphabet]
                  for i in range(nodes_number)
              ]
          for i in range(nodes_number):
              line = fin.readline().strip()
              if "\t" in line:
                  label, transitions = line.split("\t")
                  final[i] = label == "T"
              else:
                  label = line
                  final[i] = label == "T"
                  continue
              transitions = [x.split(":") for x in transitions.split()]
              for code, value in transitions:
                  graph[i][int(code)] = int(value)
          trie.graph = graph
          trie.root = root
          trie.final = final
          trie.nodes_number = nodes_number
          trie.data = [None] * nodes_number
          if read_data:
              for i in range(nodes_number):
                  line = fin.readline().strip("\n")
                  trie.data[i] = [
                      set(elem.split(",")) for elem in line.split(":")
                  ]
          if trie.to_make_cashed:
              trie.make_cashed()
          return trie
  
imports: import copy
  from collections import defaultdict
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: load_trie(infile) and returns: trie