code: def select_class_id(
      class_id: int,
      labels: Any,
      predictions: Any,
      sparse_labels: bool = None,
  ) -> Tuple[np.ndarray, np.ndarray]:
      """Selects values for given class ID from multi-class labels and predictions.
  
      Args:
        class_id: Class ID to filter the labels and predictions by.
        labels: Array or list of processed labels (1D, 2D, or 3D).
        predictions: Array or list of processed predictions (1D, 2D, or 3D).
        sparse_labels: True if sparse labels are being used. If None then the
          sparseness will be inferred from the shapes of the labels and predictions
          (i.e. if the shapes are different then the labels will be assumed to be
          sparse).
  
      Returns:
        A (labels, predictions) tuple with the predictions returned in the same form
        as the originals (except for the last dimension which will be 1).
  
      Raises:
        ValueError: If the labels or predictions cannot be formatted properly.
      """
      labels = util.to_numpy(labels)
      predictions = util.to_numpy(predictions)
      if labels.size == 0 or predictions.size == 0:
          return (labels, predictions)
  
      def lookup(arr, target):
          if class_id < 0 or class_id >= len(arr):
              raise ValueError(
                  f'class_id "{class_id}" out of range of {target}: {arr}'
              )
          return arr[class_id]
  
      # Convert scalars to arrays
      if not labels.shape:
          labels = labels.reshape((1,))
      if not predictions.shape:
          predictions = predictions.reshape((1,))
  
      sparse_labels = _verify_sparse_labels(
          labels, predictions, sparse_labels=sparse_labels
      )
      if sparse_labels and labels.shape[-1] != 1:
          # Convert to [[class_id1], ...]
          labels = labels.reshape((-1, 1))
  
      labels_out_shape = list(labels.shape)
      labels_out_shape[-1] = 1
      predictions_out_shape = list(predictions.shape)
      predictions_out_shape[-1] = 1
  
      # Convert labels and predictions into the form ([[...], [...]])
      if len(labels.shape) > 1:
          # Flatten all but the last dim (a, b, c) -> (a * b, c)
          labels = labels.reshape((-1, labels.shape[-1]))
      else:
          labels = labels.reshape((1, labels.shape[0]))
      if len(predictions.shape) > 1:
          predictions = predictions.reshape((-1, predictions.shape[-1]))
      else:
          predictions = predictions.reshape((1, predictions.shape[0]))
  
      if sparse_labels:
          # Labels are of the form [[class_id1], [class_id2], ...]
          labels = np.array([int(l[0] == class_id) for l in labels])
      else:
          # Labels are of the form [[0, 0, 1, ...], [0, 0, 0, ...], ...]
          labels = np.array([lookup(l, "labels") for l in labels])
      predictions = np.array(
          [lookup(p, "predictions") for p in predictions]
      )
  
      return (
          labels.reshape(labels_out_shape),
          predictions.reshape(predictions_out_shape),
      )
  
imports: import inspect
  import math
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow_model_analysis import constants
  from tensorflow_model_analysis.api import types
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.utils import util
  from tensorflow_metadata.proto.v0 import schema_pb2
label_desc: Use image node_id 23 for calling a global function with example usage: select_class_id(class_id, labels, predictions, sparse_labels) and returns: labels,  predictions, labels,  predictions, arr