code: def check_state(self, tgt_generated):
      if tgt_generated[-1] == self.tokenizer.pad_token_id:
          return "start", -1
  
      # special_token_set = {EVENT_TYPE_LEFT, EVENT_TYPE_RIGHT}
      special_token_set = {
          self.type_start,
          self.type_end,
          self.span_start,
      }
      special_index_token = list(
          filter(
              lambda x: x[1] in special_token_set,
              list(enumerate(tgt_generated)),
          )
      )
  
      last_special_index, last_special_token = special_index_token[-1]
  
      if len(special_index_token) == 1:
          if last_special_token != self.type_start:
              return "error", 0
  
      bracket_position = find_bracket_position(
          tgt_generated,
          _type_start=self.type_start,
          _type_end=self.type_end,
      )
      start_number, end_number = len(
          bracket_position[self.type_start]
      ), len(bracket_position[self.type_end])
  
      if start_number == end_number:
          return "end_generate", -1
      if start_number == end_number + 1:
          state = "start_first_generation"
      elif start_number == end_number + 2:
          state = "generate_trigger"
          if last_special_token == self.span_start:
              state = "generate_trigger_text"
      elif start_number == end_number + 3:
          state = "generate_role"
          if last_special_token == self.span_start:
              state = "generate_role_text"
      else:
          state = "error"
      return state, last_special_index
  
file_path: DeepKE/src/deepke/name_entity_re/cross/seq2seq/constraint_decoder/spotasoc_constraint_decoder.py
imports: import os
  from typing import List, Dict
  from ...extraction.label_tree import get_label_name_tree
  from ...extraction.constants import span_start, type_start, type_end, null_span, text_start
  from ...seq2seq.constraint_decoder.constraint_decoder import ConstraintDecoder, find_bracket_position, generated_search_src_sequence
label_desc: Use image node_id 2 for calling the SpotAsocConstraintDecoder obj's underlying member method code with example usage: obj.check_state(tgt_generated) and returns: state,  last_special_index, str,  unknown, str,  unknown, str,  int