code: def select_indices(
      arr: np.ndarray,
      indices: Union[np.ndarray, Tuple[np.ndarray, np.ndarray]],
  ) -> np.ndarray:
      """Selects values from tensor at given indices.
  
      Args:
        arr: Array to select values from.
        indices: Indices that are given either by an np.ndarray (1D) or a tuple of
          np.ndarray's where the first value identifies the rows and the second the
          columns (2D).
  
      Returns:
        Values with the same shape as tensor except the last dimension will match
        the number of indices selected.
      """
      values = arr[indices]
      if len(arr.shape) == 1:
          return values
      elif len(arr.shape) == 2:
          # The indices[0] contains rows of the form [row1, row1, ..., row2, ...]
          # the rows are repeated for each column. Since the first dimension of the
          # array tells us the number of rows, dividing the length of indices[0] by
          # the number of rows tells us the number of columns we are returning (i.e.
          # the size of the last dim).
          last_dim = int(len(indices[0]) / arr.shape[0])
          values = values.reshape(arr.shape[:-1] + (last_dim,))
          return values
      else:
          raise NotImplementedError(
              "select_indices not supported for shapes > 2: "
              "arr={}, indices={}".format(arr, indices)
          )
  
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 16 for calling a global function with example usage: select_indices(arr, indices) and returns: values, values