class_docstr: This loop is the top-level loop where training starts.
  
  It simply counts the epochs and iterates from one to the next by calling ``TrainingEpochLoop.run()`` in its
  ``advance()`` method.
  
  Example::
  
      # FitLoop
      for epoch in range(max_epochs):
          # TrainingEpochLoop
          for batch_idx, batch in enumerate(train_dataloader):
              loss = lightning_module.training_step(batch, batch_idx)
              ...
  
              # ValidationEpochLoop
              for batch_idx, batch in enumerate(val_dataloader):
                  lightning_module.validation_step(batch, batch_idx)
                  ...
              ...
          ...
  
  Args:
      min_epochs: The minimum number of epochs
      max_epochs: The maximum number of epochs, can be set -1 to turn this limit off
class_docstr_tok: ["This","loop","is","the","top-level","loop","where","training","starts",".","It","simply","counts","the","epochs","and","iterates","from","one","to","the","next","by","calling","``","TrainingEpochLoop.run","(",")","``","in","its","``","advance","(",")","``","method",".","Example",":",":","#","FitLoop","for","epoch","in","range","(","max_epochs",")",":","#","TrainingEpochLoop","for","batch_idx",",","batch","in","enumerate","(","train_dataloader",")",":","loss","=","lightning_module.training_step","(","batch",",","batch_idx",")","...","#","ValidationEpochLoop","for","batch_idx",",","batch","in","enumerate","(","val_dataloader",")",":","lightning_module.validation_step","(","batch",",","batch_idx",")","...","...","...","Args",":","min_epochs",":","The","minimum","number","of","epochs","max_epochs",":","The","maximum","number","of","epochs",",","can","be","set","-1","to","turn","this","limit","off"]
code: def setup_data(self) -> None:
      if (
          self._combined_loader is not None
          and not self._should_reload_train_dl
      ):
          return
  
      trainer = self.trainer
      pl_module = trainer.lightning_module
      if trainer.limit_train_batches == 0 or not is_overridden(
          "training_step", pl_module
      ):
          return
  
      log.debug(
          f"{self.__class__.__name__}: resetting train dataloader"
      )
  
      source = self._data_source
      train_dataloader = _request_dataloader(source)
      trainer.strategy.barrier("train_dataloader()")
  
      if not isinstance(train_dataloader, CombinedLoader):
          combined_loader = CombinedLoader(
              train_dataloader, "max_size_cycle"
          )
      else:
          combined_loader = train_dataloader
  
      if trainer.overfit_batches > 0:
          _resolve_overfit_batches(
              combined_loader, mode=RunningStage.TRAINING
          )
  
      trainer_fn = TrainerFn.FITTING
      stage = RunningStage.TRAINING
      dataloaders = []
      for dl in combined_loader.flattened:
          _check_dataloader_iterable(dl, source, trainer_fn)
          dl = _process_dataloader(trainer, trainer_fn, stage, dl)
          dataloaders.append(dl)
      combined_loader.flattened = dataloaders
      self._combined_loader = combined_loader
  
      allow_zero_length = (
          pl_module.allow_zero_length_dataloader_with_multiple_devices
      )
      if trainer.datamodule is not None:
          allow_zero_length |= (
              trainer.datamodule.allow_zero_length_dataloader_with_multiple_devices
          )
  
      limits = []
      for dl in combined_loader.flattened:
          # determine number of batches
          length = (
              len(dl)
              if has_len_all_ranks(
                  dl, trainer.strategy, allow_zero_length
              )
              else float("inf")
          )
          num_batches = _parse_num_batches(
              stage, length, trainer.limit_train_batches
          )
          limits.append(num_batches)
  
      combined_loader.limits = limits
  
      self._data_fetcher = _select_data_fetcher(
          trainer, RunningStage.TRAINING
      )
      self._data_fetcher.setup(combined_loader)
      iter(
          self._data_fetcher
      )  # creates the iterator inside the fetcher
      max_batches = sized_len(combined_loader)
      self.max_batches = (
          max_batches if max_batches is not None else float("inf")
      )
      has_len_all_ranks_ = has_len_all_ranks(
          combined_loader, trainer.strategy, allow_zero_length
      )
  
      if self.max_batches == 0:
          return
  
      # store epoch of dataloader reset for reload_dataloaders_every_n_epochs
      self._last_train_dl_reload_epoch = trainer.current_epoch
  
      if isinstance(trainer.val_check_interval, int):
          trainer.val_check_batch = trainer.val_check_interval
          if (
              trainer.val_check_batch > self.max_batches
              and trainer.check_val_every_n_epoch is not None
          ):
              raise ValueError(
                  f" `val_check_interval` ({trainer.val_check_interval}) must be less than or equal"
                  f" to the number of the training batches ({self.max_batches})."
                  " If you want to disable validation set `limit_val_batches` to 0.0 instead."
                  " If you want to validate based on the total training batches, set `check_val_every_n_epoch=None`."
              )
      else:
          if not has_len_all_ranks_:
              if trainer.val_check_interval == 1.0:
                  trainer.val_check_batch = float("inf")
              else:
                  raise MisconfigurationException(
                      "When using an IterableDataset for `train_dataloader`,"
                      " `Trainer(val_check_interval)` must be `1.0` or an int. An int k specifies"
                      " checking validation every k training batches."
                  )
          else:
              trainer.val_check_batch = int(
                  self.max_batches * trainer.val_check_interval
              )
              trainer.val_check_batch = max(1, trainer.val_check_batch)
  
      if (
          trainer.loggers
          and self.max_batches < trainer.log_every_n_steps
          and not trainer.fast_dev_run
      ):
          rank_zero_warn(
              f"The number of training batches ({self.max_batches}) is smaller than the logging interval"
              f" Trainer(log_every_n_steps={trainer.log_every_n_steps}). Set a lower value for log_every_n_steps if"
              " you want to see logs for the training epoch.",
              category=PossibleUserWarning,
          )
  
imports: import logging
  from typing import Optional, Union
  import torch
  from typing_extensions import override
  import lightning.pytorch
  from lightning.fabric.utilities.data import _set_sampler_epoch, sized_len
  from lightning.fabric.utilities.warnings import PossibleUserWarning
  from lightning.pytorch.loops import _Loop
  from lightning.pytorch.loops.fetchers import _DataFetcher
  from lightning.pytorch.loops.progress import _Progress
  from lightning.pytorch.loops.training_epoch_loop import _TrainingEpochLoop
  from lightning.pytorch.loops.utilities import _is_max_limit_reached, _select_data_fetcher
  from lightning.pytorch.trainer import call
  from lightning.pytorch.trainer.connectors.data_connector import _check_dataloader_iterable, _DataLoaderSource, _parse_num_batches, _process_dataloader, _request_dataloader, _resolve_overfit_batches
  from lightning.pytorch.trainer.connectors.logger_connector.result import _ResultCollection
  from lightning.pytorch.trainer.states import RunningStage, TrainerFn
  from lightning.pytorch.utilities.combined_loader import _SUPPORTED_MODES, CombinedLoader
  from lightning.pytorch.utilities.data import has_len_all_ranks
  from lightning.pytorch.utilities.exceptions import MisconfigurationException, SIGTERMException
  from lightning.pytorch.utilities.model_helpers import is_overridden
  from lightning.pytorch.utilities.rank_zero import rank_zero_debug, rank_zero_info, rank_zero_warn
label_desc: Use image node_id 15 for calling the _FitLoop obj's underlying member method code with example usage: obj.setup_data() without return types