docstr: Generate Type Name + Text Span
  :param generated:
  :param prefix_tree:
  :param src_sentence:
  :param end_sequence_search_tokens:
  :return:
docstr_tok: ["Generate","Type","Name","+","Text","Span",":","param","generated",":",":","param","prefix_tree",":",":","param","src_sentence",":",":","param","end_sequence_search_tokens",":",":","return",":"]
code: def search_prefix_tree_and_sequence(
      self,
      generated: List[str],
      prefix_tree: Dict,
      src_sentence: List[str],
      end_sequence_search_tokens: List[str] = None,
  ):
      """
      Generate Type Name + Text Span
      :param generated:
      :param prefix_tree:
      :param src_sentence:
      :param end_sequence_search_tokens:
      :return:
      """
      tree = prefix_tree
      for index, token in enumerate(generated):
          tree = tree[token]
          is_tree_end = len(tree) == 1 and self.tree_end in tree
  
          if is_tree_end:
              valid_token = generated_search_src_sequence(
                  generated=generated[index + 1 :],
                  src_sequence=src_sentence,
                  end_sequence_search_tokens=end_sequence_search_tokens,
              )
              return valid_token
  
          if self.tree_end in tree:
              try:
                  valid_token = generated_search_src_sequence(
                      generated=generated[index + 1 :],
                      src_sequence=src_sentence,
                      end_sequence_search_tokens=end_sequence_search_tokens,
                  )
                  return valid_token
              except IndexError:
                  # Still search tree
                  continue
  
      valid_token = list(tree.keys())
      return valid_token
  
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 3 for calling the SpotAsocConstraintDecoder obj's underlying member method code with example usage: obj.search_prefix_tree_and_sequence(generated, prefix_tree, src_sentence, end_sequence_search_tokens) and returns: valid_token, valid_token, valid_token