code: def test_unary_requires_root(model=None):
      if model is None:
          model = SimpleModel(
              transition_scheme=TransitionScheme.TOP_DOWN_UNARY
          )
      state = build_initial_state(model)[0]
  
      open_transition = parse_transitions.OpenConstituent("S")
      assert open_transition.is_legal(state, model)
      state = open_transition.apply(state, model)
  
      shift = parse_transitions.Shift()
      assert shift.is_legal(state, model)
      state = shift.apply(state, model)
      assert shift.is_legal(state, model)
      state = shift.apply(state, model)
      assert shift.is_legal(state, model)
      state = shift.apply(state, model)
      assert not shift.is_legal(state, model)
  
      close_transition = parse_transitions.CloseConstituent()
      assert close_transition.is_legal(state, model)
      state = close_transition.apply(state, model)
      assert not open_transition.is_legal(state, model)
      assert not close_transition.is_legal(state, model)
  
      np_unary = parse_transitions.CompoundUnary("NP")
      assert not np_unary.is_legal(state, model)
      root_unary = parse_transitions.CompoundUnary("ROOT")
      assert root_unary.is_legal(state, model)
      assert not state.finished(model)
      state = root_unary.apply(state, model)
      assert not root_unary.is_legal(state, model)
  
      assert state.finished(model)
  
imports: import pytest
  from stanza.models.constituency import parse_transitions
  from stanza.models.constituency.base_model import SimpleModel, UNARY_LIMIT
  from stanza.models.constituency.parse_transitions import TransitionScheme, Shift, CloseConstituent, OpenConstituent
  from stanza.tests import *
label_desc: Use image node_id 6 for calling a global function with example usage: test_unary_requires_root(model) without return types