code: def select_labels(
      labels: Sequence[NdarrayOrTensor] | NdarrayOrTensor,
      keep: NdarrayOrTensor,
  ) -> tuple | NdarrayOrTensor:
      """
      For element in labels, select indices keep from it.
  
      Args:
          labels: Sequence of array. Each element represents classification labels or scores
              corresponding to ``boxes``, sized (N,).
          keep: the indices to keep, same length with each element in labels.
  
      Return:
          selected labels, does not share memory with original labels.
      """
      labels_tuple = ensure_tuple(labels, True)
  
      labels_select_list = []
      keep_t: torch.Tensor = convert_data_type(keep, torch.Tensor)[0]
      for item in labels_tuple:
          labels_t: torch.Tensor = convert_data_type(
              item, torch.Tensor
          )[0]
          labels_t = labels_t[keep_t, ...]
          labels_select_list.append(
              convert_to_dst_type(src=labels_t, dst=item)[0]
          )
  
      if isinstance(labels, (torch.Tensor, np.ndarray)):
          return labels_select_list[0]  # type: ignore
  
      return tuple(labels_select_list)
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  from copy import deepcopy
  import numpy
  import torch
  from monai.config.type_definitions import DtypeLike, NdarrayOrTensor, NdarrayTensor
  from monai.data.box_utils import COMPUTE_DTYPE, TO_REMOVE, get_spatial_dims
  from monai.transforms import Resize
  from monai.transforms.utils import create_scale
  from monai.utils import look_up_option
  from monai.utils.misc import ensure_tuple, ensure_tuple_rep
  from monai.utils.type_conversion import convert_data_type, convert_to_dst_type
label_desc: Use image node_id 8 for calling a global function with example usage: select_labels(labels, keep) and returns: tuple, labels_select_list