code: def yield_top_down_sequence(
      tree, transition_scheme=TransitionScheme.TOP_DOWN_UNARY
  ):
      """
      For tree (X A B C D), yield Open(X) A B C D Close
  
      The details are in how to treat unary transitions
      Three possibilities handled by this method:
        TOP_DOWN_UNARY:    (Y (X ...)) -> Open(X) ... Close Unary(Y)
        TOP_DOWN_COMPOUND: (Y (X ...)) -> Open(Y, X) ... Close
        TOP_DOWN:          (Y (X ...)) -> Open(Y) Open(X) ... Close Close
      """
      if tree.is_preterminal():
          yield Shift()
          return
  
      if tree.is_leaf():
          return
  
      if transition_scheme is TransitionScheme.TOP_DOWN_UNARY:
          if len(tree.children) == 1:
              labels = []
              while (
                  not tree.is_preterminal() and len(tree.children) == 1
              ):
                  labels.append(tree.label)
                  tree = tree.children[0]
              for transition in yield_top_down_sequence(
                  tree, transition_scheme
              ):
                  yield transition
              yield CompoundUnary(*labels)
              return
  
      if transition_scheme is TransitionScheme.TOP_DOWN_COMPOUND:
          labels = [tree.label]
          while (
              len(tree.children) == 1
              and not tree.children[0].is_preterminal()
          ):
              tree = tree.children[0]
              labels.append(tree.label)
          yield OpenConstituent(*labels)
      else:
          yield OpenConstituent(tree.label)
      for child in tree.children:
          for transition in yield_top_down_sequence(
              child, transition_scheme
          ):
              yield transition
      yield CloseConstituent()
  
file_path: stanza/stanza/models/constituency/transition_sequence.py
imports: import logging
  from stanza.models.common import utils
  from stanza.models.constituency.parse_transitions import Shift, CompoundUnary, OpenConstituent, CloseConstituent, TransitionScheme, Finalize
  from stanza.models.constituency.tree_reader import read_trees
  from stanza.utils.get_tqdm import get_tqdm
label_desc: Use image node_id 1 for calling a global function with example usage: yield_top_down_sequence(tree, transition_scheme) without return types