code: def fix_shift_close(
      gold_transition,
      pred_transition,
      gold_sequence,
      gold_index,
      root_labels,
  ):
      """
      This fixes Shift replaced with a Close transition.
  
      This error occurs in the following pattern:
        stuff_1 NT_X stuff... shift
      Instead of shift, you close the NT_X
      The easiest fix here is to just restore the NT_X.
      """
  
      if not isinstance(pred_transition, CloseConstituent):
          return None
  
      # this fix can also be applied if there were unaries on the
      # previous constituent.  we just skip those until the Shift
      cur_index = gold_index
      if isinstance(gold_transition, OpenConstituent):
          cur_index = advance_past_unaries(gold_sequence, cur_index)
      if not isinstance(gold_sequence[cur_index], Shift):
          return None
  
      prev_open_index = find_previous_open(gold_sequence, gold_index)
      if prev_open_index is None:
          return None
      prev_open = gold_sequence[prev_open_index]
      # prev_open is now NT_X from above
  
      return (
          gold_sequence[:gold_index]
          + [pred_transition, prev_open]
          + gold_sequence[cur_index:]
      )
  
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 12 for calling a global function with example usage: fix_shift_close(gold_transition, pred_transition, gold_sequence, gold_index, root_labels) and returns: unknown, None, None, None