class_docstr: Top-level loop where prediction starts.
class_docstr_tok: ["Top-level","loop","where","prediction","starts","."]
code: def __init__(
      self, trainer: "pl.Trainer", inference_mode: bool = True
  ) -> None:
      super().__init__(trainer)
      self.inference_mode = inference_mode
      # dataloaders x batches x samples. used by PredictionWriter
      self.epoch_batch_indices: List[List[List[int]]] = []
      self.current_batch_indices: List[
          int
      ] = []  # used by PredictionWriter
      self.batch_progress = _Progress()  # across dataloaders
      self.max_batches: List[Union[int, float]] = []
  
      self._warning_cache = WarningCache()
      self._data_source = _DataLoaderSource(None, "predict_dataloader")
      self._combined_loader: Optional[CombinedLoader] = None
      self._data_fetcher: Optional[_DataFetcher] = None
      self._results = None  # for `trainer._results` access
      self._predictions: List[List[Any]] = []  # dataloaders x batches
      self._return_predictions = False
      self._module_mode = _ModuleMode()
  
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 1 to create a new _PredictionLoop object from inherited base classes: _Loop with example: obj = _PredictionLoop(trainer, inference_mode)