class_docstr: Top-level loop where prediction starts.
class_docstr_tok: ["Top-level","loop","where","prediction","starts","."]
code: def setup_data(self) -> None:
      trainer = self.trainer
      # a default `predict_step` exists in the LightningModule, so no need to check if it's overridden
      if trainer.limit_predict_batches == 0:
          return
  
      source = self._data_source
      dataloaders = _request_dataloader(source)
      trainer.strategy.barrier("predict_dataloader()")
  
      if not isinstance(dataloaders, CombinedLoader):
          combined_loader = CombinedLoader(dataloaders, "sequential")
      else:
          combined_loader = dataloaders
  
      allow_zero_length = (
          trainer.lightning_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
          )
  
      trainer_fn = TrainerFn.PREDICTING
      stage = RunningStage.PREDICTING
      dataloaders = []
      self.max_batches = []
      for dl in combined_loader.flattened:
          _check_dataloader_iterable(dl, source, trainer_fn)
          dl = _process_dataloader(trainer, trainer_fn, stage, dl)
          dataloaders.append(dl)
  
          # 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_predict_batches
          )
          self.max_batches.append(num_batches)
      combined_loader.flattened = dataloaders
      self._combined_loader = combined_loader
  
imports: from collections import OrderedDict
  from typing import Any, Iterator, List, Optional, Union
  import torch
  from lightning_utilities import WarningCache
  import lightning.pytorch
  from lightning.fabric.utilities import move_data_to_device
  from lightning.pytorch.callbacks import BasePredictionWriter
  from lightning.pytorch.loops.fetchers import _DataFetcher, _DataLoaderIterDataFetcher
  from lightning.pytorch.loops.loop import _Loop
  from lightning.pytorch.loops.progress import _Progress
  from lightning.pytorch.loops.utilities import _no_grad_context, _select_data_fetcher, _verify_dataloader_idx_requirement
  from lightning.pytorch.overrides.distributed import _IndexBatchSamplerWrapper
  from lightning.pytorch.strategies.launchers import _MultiProcessingLauncher
  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
  from lightning.pytorch.trainer.states import RunningStage, TrainerFn
  from lightning.pytorch.utilities.combined_loader import CombinedLoader
  from lightning.pytorch.utilities.data import has_len_all_ranks
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.model_helpers import _ModuleMode
  from lightning.pytorch.utilities.signature_utils import is_param_in_hook_signature
  from lightning.pytorch.utilities.types import _PREDICT_OUTPUT
label_desc: Use image node_id 8 for calling the _PredictionLoop obj's underlying member method code with example usage: obj.setup_data() without return types