code: def find_constituent_end(gold_sequence, cur_index):
      """
      Advance cur_index through gold_sequence until the next block has ended
  
      This is different from advance_past_constituents in that it will
      also return when there is a Shift when count == 0.  That way, we
      return the first block of things we know attach to the left
      """
      count = 0
      saw_shift = False
      while cur_index < len(gold_sequence):
          if isinstance(gold_sequence[cur_index], OpenConstituent):
              count = count + 1
          elif isinstance(gold_sequence[cur_index], CloseConstituent):
              count = count - 1
              if count == -1:
                  return cur_index
          elif isinstance(gold_sequence[cur_index], Shift):
              if saw_shift and count == 0:
                  return cur_index
              else:
                  saw_shift = True
          cur_index = cur_index + 1
      return None
  
imports: from enum import Enum, auto
  from stanza.models.constituency.dynamic_oracle import DynamicOracle
  from stanza.models.constituency.parse_transitions import Shift, OpenConstituent, CloseConstituent
label_desc: Use image node_id 4 for calling a global function with example usage: find_constituent_end(gold_sequence, cur_index) and returns: None, cur_index, cur_index