code: def create_iterator(
      train_func,
      backend_config,
      *,
      num_workers=2,
      backend_executor_cls=BackendExecutor,
      init_hook=None,
  ):
      # Similar logic to the old Trainer.run_iterator().
  
      train_func = construct_train_func(train_func, None)
  
      backend_executor = backend_executor_cls(
          backend_config=backend_config,
          num_workers=num_workers,
          max_retries=MAX_RETRIES,
      )
      backend_executor.start(init_hook)
  
      return TrainingIterator(
          backend_executor=backend_executor,
          backend_config=backend_config,
          train_func=train_func,
          datasets={},
          metadata={},
          data_config=DataConfig(),
          checkpoint=None,
      )
  
imports: import functools
  import time
  from unittest.mock import patch
  import pytest
  import ray
  from ray import train
  from ray.air._internal.util import StartTraceback
  from ray.train import DataConfig
  from ray.train._internal.backend_executor import BackendExecutor
  from ray.train._internal.session import get_session, init_session
  from ray.train._internal.utils import construct_train_func
  from ray.train._internal.worker_group import WorkerGroup
  from ray.train.backend import BackendConfig
  from ray.train.examples.pytorch.torch_linear_example import train_func
  from ray.train.examples.tf.tensorflow_mnist_example import train_func
  from ray.train.tests.util import mock_storage_context
  from ray.train.trainer import TrainingIterator
label_desc: Use image node_id 5 for calling a global function with example usage: create_iterator(train_func, backend_config) and returns: TrainingIterator