code: def train_val_split(
      X, labels, train_idx, holdout_idx
  ) -> Tuple[DatasetLike, DatasetLike, LabelLike, LabelLike]:
      """Splits data into training/validation sets based on given indices"""
      labels_train, labels_holdout = (
          labels[train_idx],
          labels[holdout_idx],
      )  # labels are always np.ndarray
      split_completed = False
      if isinstance(X, (pd.DataFrame, pd.Series)):
          X_train, X_holdout = X.iloc[train_idx], X.iloc[holdout_idx]
          split_completed = True
      if not split_completed:
          try:  # check if X is pytorch Dataset object using lazy import
              import torch
  
              if isinstance(
                  X, torch.utils.data.Dataset
              ):  # special splitting for pytorch Dataset
                  X_train = torch.utils.data.Subset(X, train_idx)
                  X_holdout = torch.utils.data.Subset(X, holdout_idx)
                  split_completed = True
          except Exception:
              pass
      if not split_completed:
          try:  # check if X is tensorflow Dataset object using lazy import
              import tensorflow
  
              if isinstance(
                  X, tensorflow.data.Dataset
              ):  # special splitting for tensorflow Dataset
                  X_train = extract_indices_tf(
                      X, train_idx, allow_shuffle=True
                  )
                  X_holdout = extract_indices_tf(
                      X, holdout_idx, allow_shuffle=False
                  )
                  split_completed = True
          except Exception:
              pass
      if not split_completed:
          try:
              X_train, X_holdout = X[train_idx], X[holdout_idx]
          except Exception:
              raise ValueError(
                  "Cleanlab cannot split this form of dataset (required for cross-validation). "
                  "Try a different data format, "
                  "or implement the cross-validation yourself and instead provide out-of-sample `pred_probs`"
              )
  
      return X_train, X_holdout, labels_train, labels_holdout
  
imports: import warnings
  import numpy
  import pandas
  from typing import Union, Tuple
  from cleanlab.typing import DatasetLike, LabelLike
  from cleanlab.internal.validation import labels_to_array
  from cleanlab.internal.constants import FLOATING_POINT_COMPARISON, TINY_VALUE
label_desc: Use image node_id 16 for calling a global function with example usage: train_val_split(X, labels, train_idx, holdout_idx) and returns: X_train,  X_holdout,  labels_train,  labels_holdout