class_docstr: Handles iterating over epoch-level `tp.Iterator` objects.
class_docstr_tok: ["Handles","iterating","over","epoch-level","`","tp.Iterator","`","objects","."]
docstr: Catches errors when an iterator runs out of data.
docstr_tok: ["Catches","errors","when","an","iterator","runs","out","of","data","."]
code: def catch_stop_iteration(self):
      """Catches errors when an iterator runs out of data."""
      try:
          yield
          # context.async_wait()
  
      except StopIteration:
          if (
              self._adapter.get_size() is None
              and self._inferred_steps is None
              and self._current_step > 0
          ):
              # The input passed by the user ran out of batches.
              # Now we know the cardinality of the input(dataset or generator).
              self._inferred_steps = self._current_step
          else:
              self._insufficient_data = True
              total_epochs = self._epochs - self._initial_epoch
              logging.warning(
                  "Your input ran out of data; interrupting training. "
                  "Make sure that your dataset or generator can generate at "
                  "least `steps_per_epoch * epochs` batches (in this case, "
                  "{} batches). You may need to use the repeat() function "
                  "if using tf.data.Dataset.".format(
                      total_epochs * self._inferred_steps
                  )
              )
  
file_path: elegy/elegy/data/data_handler.py
imports: import contextlib
  import logging
  from .array_adapter import ArrayDataAdapter
  from .dataset import DataLoaderAdapter
  from .generator_adapter import GeneratorDataAdapter
  from .list_adapter import ListsOfScalarsDataAdapter
label_desc: Use image node_id 3 for calling the DataHandler obj's underlying member method code with example usage: obj.catch_stop_iteration() without return types