code: def _get_data_iterator_from_dataset(dataset, dataset_type_spec):
      """Get the iterator from a dataset.
  
      Args:
          dataset: A `tf.data.Dataset`, a `torch.utils.data.Dataset` object,
              or a list/tuple of arrays.
          dataset_type_spec: The type of the dataset.
  
      Returns:
          iterator: An `iterator` object.
      """
      if dataset_type_spec == list:
          if len(dataset) == 0:
              raise ValueError(
                  "Received an empty list dataset. "
                  "Please provide a non-empty list of arrays."
              )
  
          if _get_type_spec(dataset[0]) is np.ndarray:
              expected_shape = dataset[0].shape
              for i, element in enumerate(dataset):
                  if np.array(element).shape[0] != expected_shape[0]:
                      raise ValueError(
                          "Received a list of NumPy arrays with different "
                          f"lengths. Mismatch found at index {i}, "
                          f"Expected shape={expected_shape} "
                          f"Received shape={np.array(element).shape}."
                          "Please provide a list of NumPy arrays with "
                          "the same length."
                      )
          else:
              raise ValueError(
                  "Expected a list of `numpy.ndarray` objects,"
                  f"Received: {type(dataset[0])}"
              )
  
          return iter(zip(*dataset))
      elif dataset_type_spec == tuple:
          if len(dataset) == 0:
              raise ValueError(
                  "Received an empty list dataset."
                  "Please provide a non-empty tuple of arrays."
              )
  
          if _get_type_spec(dataset[0]) is np.ndarray:
              expected_shape = dataset[0].shape
              for i, element in enumerate(dataset):
                  if np.array(element).shape[0] != expected_shape[0]:
                      raise ValueError(
                          "Received a tuple of NumPy arrays with different "
                          f"lengths. Mismatch found at index {i}, "
                          f"Expected shape={expected_shape} "
                          f"Received shape={np.array(element).shape}."
                          "Please provide a tuple of NumPy arrays with "
                          "the same length."
                      )
          else:
              raise ValueError(
                  "Expected a tuple of `numpy.ndarray` objects, "
                  f"Received: {type(dataset[0])}"
              )
  
          return iter(zip(*dataset))
      elif dataset_type_spec == tf.data.Dataset:
          if is_batched(dataset):
              dataset = dataset.unbatch()
          return iter(dataset)
  
      elif is_torch_dataset(dataset):
          return iter(dataset)
      elif dataset_type_spec == np.ndarray:
          return iter(dataset)
      raise ValueError(
          f"Invalid dataset_type_spec: {dataset_type_spec}"
      )
  
imports: import os
  import random
  import time
  import warnings
  from multiprocessing.pool import ThreadPool
  import numpy
  from keras.api_export import keras_export
  from keras.utils import io_utils
  from keras.utils.module_utils import tensorflow
label_desc: Use image node_id 3 for calling a global function with example usage: _get_data_iterator_from_dataset(dataset, dataset_type_spec) and returns: iter, iter, iter, iter, iter