class_docstr: Records progress through the set of constraints for each item in the beam
  using a trie.
class_docstr_tok: ["Records","progress","through","the","set","of","constraints","for","each","item","in","the","beam","using","a","trie","."]
code: def __init__(
      self, node: ConstraintNode, copy_from: "ConstraintState" = None
  ):
      self.node = node
  
      if copy_from is None:
          # The root node
          self.root = node
          # The set of states in the graph that have been completed
          self.completed = Counter()
          # The...
          self.generated = Counter()
          # The list of tokens we need to generate
          self.needed_tokens = self.root.tokens()
      else:
          self.completed = Counter(copy_from.completed)
          self.generated = Counter(copy_from.generated)
          self.root = copy_from.root
  
      # Mark the node as generated
      if self.node != self.root:
          self.generated[node] += 1
  
imports: from collections import Counter
  from typing import List, Optional, Set, Tuple
  import torch
label_desc: Use image node_id 1 to create a new UnorderedConstraintState object from inherited base classes: ConstraintState with example: obj = UnorderedConstraintState(node, copy_from)