code: def _find_bilou_end(
      start_idx: int, predicted_tags: List[Text]
  ) -> int:
      """Find the last index of the entity.
  
      The start index is pointing to a B- tag. The entity is closed as soon as we find
      a L- tag or a O tag.
  
      Args:
          start_idx: The start index of the entity
          predicted_tags: The list of predicted tags
  
      Returns:
          The end index of the entity
      """
      current_idx = start_idx + 1
      finished = False
      start_tag = tag_without_prefix(predicted_tags[start_idx])
  
      while not finished:
          if current_idx >= len(predicted_tags):
              logger.debug(
                  "Inconsistent BILOU tagging found, B- tag not closed by L- tag, "
                  "i.e [B-a, I-a, O] instead of [B-a, L-a, O].\n"
                  "Assuming last tag is L- instead of I-."
              )
              current_idx -= 1
              break
  
          current_label = predicted_tags[current_idx]
          prefix = bilou_prefix_from_tag(current_label)
          tag = tag_without_prefix(current_label)
  
          if tag != start_tag:
              # words are not tagged the same entity class
              logger.debug(
                  "Inconsistent BILOU tagging found, B- tag, L- tag pair encloses "
                  "multiple entity classes.i.e. [B-a, I-b, L-a] instead of "
                  "[B-a, I-a, L-a].\nAssuming B- class is correct."
              )
  
          if prefix == LAST:
              finished = True
          elif prefix == INSIDE:
              # middle part of the entity
              current_idx += 1
          else:
              # entity not closed by an L- tag
              finished = True
              current_idx -= 1
              logger.debug(
                  "Inconsistent BILOU tagging found, B- tag not closed by L- tag, "
                  "i.e [B-a, I-a, O] instead of [B-a, L-a, O].\n"
                  "Assuming last tag is L- instead of I-."
              )
  
      return current_idx
  
imports: import logging
  import operator
  from collections import defaultdict, Counter
  from typing import List, Tuple, Text, Optional, Dict, Any, TYPE_CHECKING
  from rasa.nlu.constants import TOKENS_NAMES, BILOU_ENTITIES, BILOU_ENTITIES_GROUP, BILOU_ENTITIES_ROLE
  from rasa.shared.nlu.constants import TEXT, ENTITIES, ENTITY_ATTRIBUTE_START, ENTITY_ATTRIBUTE_END, ENTITY_ATTRIBUTE_TYPE, ENTITY_ATTRIBUTE_GROUP, ENTITY_ATTRIBUTE_ROLE, NO_ENTITY_TAG
label_desc: Use image node_id 15 for calling a global function with example usage: _find_bilou_end(start_idx, predicted_tags) and returns: current_idx