code: def display_issues(
      issues: list,
      tokens: List[List[str]],
      *,
      labels: Optional[list] = None,
      pred_probs: Optional[list] = None,
      exclude: List[Tuple[int, int]] = [],
      class_names: Optional[List[str]] = None,
      top: int = 20,
  ) -> None:
      """
      Display token classification label issues, showing sentence with problematic token(s) highlighted.
  
      Can also shows given and predicted label for each token identified to have label issue.
  
      Parameters
      ----------
      issues:
          List of tuples ``(i, j)`` representing a label issue for the `j`-th token of the `i`-th sentence.
  
          Same format as output by :py:func:`token_classification.filter.find_label_issues <cleanlab.token_classification.filter.find_label_issues>`
          or :py:func:`token_classification.rank.issues_from_scores <cleanlab.token_classification.rank.issues_from_scores>`.
  
      tokens:
          Nested list such that `tokens[i]` is a list of tokens (strings/words) that comprise the `i`-th sentence.
  
      labels:
          Optional nested list of given labels for all tokens, such that `labels[i]` is a list of labels, one for each token in the `i`-th sentence.
          For a dataset with K classes, each label must be in 0, 1, ..., K-1.
  
          If `labels` is provided, this function also displays given label of the token identified with issue.
  
      pred_probs:
          Optional list of np arrays, such that `pred_probs[i]` has shape ``(T, K)`` if the `i`-th sentence contains T tokens.
  
          Each row of `pred_probs[i]` corresponds to a token `t` in the `i`-th sentence,
          and contains model-predicted probabilities that `t` belongs to each of the K possible classes.
  
          Columns of each `pred_probs[i]` should be ordered such that the probabilities correspond to class 0, 1, ..., K-1.
  
          If `pred_probs` is provided, this function also displays predicted label of the token identified with issue.
  
      exclude:
          Optional list of given/predicted label swaps (tuples) to be ignored. For example, if `exclude=[(0, 1), (1, 0)]`,
          tokens whose label was likely swapped between class 0 and 1 are not displayed. Class labels must be in 0, 1, ..., K-1.
  
      class_names:
          Optional length K list of names of each class, such that `class_names[i]` is the string name of the class corresponding to `labels` with value `i`.
  
          If `class_names` is provided, display these string names for predicted and given labels, otherwise display the integer index of classes.
  
      top: int, default=20
          Maximum number of issues to be printed.
  
      Examples
      --------
      >>> from cleanlab.token_classification.summary import display_issues
      >>> issues = [(2, 0), (0, 1)]
      >>> tokens = [
      ...     ["A", "?weird", "sentence"],
      ...     ["A", "valid", "sentence"],
      ...     ["An", "sentence", "with", "a", "typo"],
      ... ]
      >>> display_issues(issues, tokens)
      Sentence 2, token 0:
      ----
      An sentence with a typo
      ...
      ...
      Sentence 0, token 1:
      ----
      A ?weird sentence
      """
      if not class_names:
          print(
              "Classes will be printed in terms of their integer index since `class_names` was not provided. "
          )
          print(
              "Specify this argument to see the string names of each class. \n"
          )
  
      top = min(top, len(issues))
      shown = 0
      is_tuple = isinstance(issues[0], tuple)
  
      for issue in issues:
          if is_tuple:
              i, j = issue
              sentence = get_sentence(tokens[i])
              word = tokens[i][j]
  
              if pred_probs:
                  prediction = pred_probs[i][j].argmax()
              if labels:
                  given = labels[i][j]
              if pred_probs and labels:
                  if (given, prediction) in exclude:
                      continue
  
              if pred_probs and class_names:
                  prediction = class_names[prediction]
              if labels and class_names:
                  given = class_names[given]
  
              shown += 1
              print(f"Sentence index: {i}, Token index: {j}")
              print(f"Token: {word}")
              if labels and not pred_probs:
                  print(f"Given label: {given}")
              elif not labels and pred_probs:
                  print(
                      f"Predicted label according to provided pred_probs: {prediction}"
                  )
              elif labels and pred_probs:
                  print(
                      f"Given label: {given}, predicted label according to provided pred_probs: {prediction}"
                  )
              print("----")
              print(color_sentence(sentence, word))
          else:
              shown += 1
              sentence = get_sentence(tokens[issue])
              print(f"Sentence issue: {sentence}")
          if shown == top:
              break
          print("\n")
  
imports: from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import pandas
  from cleanlab.internal.token_classification_utils import color_sentence, get_sentence
label_desc: Use image node_id 1 for calling a global function with example usage: display_issues(issues, tokens) without return types