class_docstr: An iterator over Train results. Returned by ``trainer.run_iterator``.
class_docstr_tok: ["An","iterator","over","Train","results",".","Returned","by","``","trainer.run_iterator","``","."]
code: def __next__(self):
      if self.is_finished():
          raise StopIteration
      try:
          next_results = self._run_with_error_handling(
              self._fetch_next_result
          )
          if next_results is None:
              self._run_with_error_handling(self._finish_training)
              self._finished_training = True
              raise StopIteration
          else:
              return next_results
      except StartTraceback:
          # If this is a StartTraceback, then this is a user error.
          # We raise it directly
          try:
              # Exception raised in at least one training worker. Immediately raise
              # this error to the user and do not attempt to terminate gracefully.
              self._backend_executor.shutdown(
                  graceful_termination=False
              )
              self._finished_training = True
          except Exception:
              pass
          raise
  
imports: import logging
  from pathlib import Path
  from typing import Any, Callable, Dict, List, Optional, TypeVar, Union
  from ray.air._internal.util import StartTraceback
  from ray.data import Dataset
  from ray.train import Checkpoint, DataConfig
  from ray.train._internal.backend_executor import BackendExecutor, InactiveWorkerGroupError, TrainBackendError, TrainingWorkerError
  from ray.train._internal.session import _TrainingResult, _TrainSession, get_session
  from ray.train._internal.utils import ActorWrapper
  from ray.train.backend import BackendConfig
  from ray.train.base_trainer import BaseTrainer, GenDataset, TrainingFailedError
  from ray.util.annotations import DeveloperAPI
label_desc: Use image node_id 5 for calling the TrainingIterator obj's underlying member method code with example usage: obj.__next__() and returns: next_results