code: def precompute_future_symbols(trie, n, allow_spaces=False):
      """
      Collecting possible continuations of length <= n for every node
      """
      if n == 0:
          return
      if trie.is_terminated and trie.precompute_symbols:
          # символы уже предпосчитаны
          return
      for index, final in enumerate(trie.final):
          trie.data[index] = [set() for i in range(n)]
      for index, (node_data, final) in enumerate(
          zip(trie.data, trie.final)
      ):
          node_data[0] = set(trie._get_letters(index))
          if allow_spaces and final:
              node_data[0].add(" ")
      for d in range(1, n):
          for index, (node_data, final) in enumerate(
              zip(trie.data, trie.final)
          ):
              children = set(trie._get_children(index))
              for child in children:
                  node_data[d] |= trie.data[child][d - 1]
              # в случае, если разрешён возврат по пробелу в стартовое состояние
              if allow_spaces and final:
                  node_data[d] |= trie.data[trie.root][d - 1]
      trie.terminated = True
  
imports: import copy
  from collections import defaultdict
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: precompute_future_symbols(trie, n, allow_spaces) without return types