code: def _is_spanning(parse):
      d = {}
      for m, h in enumerate(parse):
          if m == h:
              return False
          d.setdefault(h, [])
          d[h].append(m)
      stack = [0]
      seen = set()
      while stack:
          cur = stack[0]
          if cur in seen:
              return False
          seen.add(cur)
          stack = d.get(cur, []) + stack[1:]
      if len(seen) != len(parse) - len([1 for p in parse if p is None]):
          return False
      return True
  
imports: import torch_struct
  import torch
  from torch_struct import LogSemiring
  import itertools
  from hypothesis.strategies import integers, composite, floats
  from hypothesis.extra.numpy import arrays
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: _is_spanning(parse) and returns: True, False, False, False