class_docstr: Base class for all strategies that change the behaviour of the training, validation and test- loop.
class_docstr_tok: ["Base","class","for","all","strategies","that","change","the","behaviour","of","the","training",",","validation","and","test-","loop","."]
docstr: Load the contents from a checkpoint and restore the state of the given objects.
  
  Args:
      path: A path to where the file is located
      state: Can be one of:
  
          - A dictionary of objects whose state will be restored in-place from the checkpoint path.
          - ``None`` or the empty dict: The loaded checkpoint will be returned in full.
          - A :class:`~torch.nn.Module` instance, if the checkpoint file contains a raw module state dict.
          - A :class:`~torch.optim.Optimizer` instance, if the checkpoint file contains a raw optimizer state.
  
      strict: Whether to enforce that the keys in `state` match the keys in the checkpoint.
  
  Returns:
      The remaining items that were not restored into the given state dictionary. If no state dictionary is
      given, the full checkpoint will be returned.
docstr_tok: ["Load","the","contents","from","a","checkpoint","and","restore","the","state","of","the","given","objects",".","Args",":","path",":","A","path","to","where","the","file","is","located","state",":","Can","be","one","of",":","-","A","dictionary","of","objects","whose","state","will","be","restored","in-place","from","the","checkpoint","path",".","-","``","None","``","or","the","empty","dict",":","The","loaded","checkpoint","will","be","returned","in","full",".","-","A",":","class",":","`","~torch.nn.Module","`","instance",",","if","the","checkpoint","file","contains","a","raw","module","state","dict",".","-","A",":","class",":","`","~torch.optim.Optimizer","`","instance",",","if","the","checkpoint","file","contains","a","raw","optimizer","state",".","strict",":","Whether","to","enforce","that","the","keys","in","`","state","`","match","the","keys","in","the","checkpoint",".","Returns",":","The","remaining","items","that","were","not","restored","into","the","given","state","dictionary",".","If","no","state","dictionary","is","given",",","the","full","checkpoint","will","be","returned","."]
code: def load_checkpoint(
      self,
      path: _PATH,
      state: Optional[
          Union[
              Module,
              Optimizer,
              Dict[str, Union[Module, Optimizer, Any]],
          ]
      ] = None,
      strict: bool = True,
  ) -> Dict[str, Any]:
      """Load the contents from a checkpoint and restore the state of the given objects.
  
      Args:
          path: A path to where the file is located
          state: Can be one of:
  
              - A dictionary of objects whose state will be restored in-place from the checkpoint path.
              - ``None`` or the empty dict: The loaded checkpoint will be returned in full.
              - A :class:`~torch.nn.Module` instance, if the checkpoint file contains a raw module state dict.
              - A :class:`~torch.optim.Optimizer` instance, if the checkpoint file contains a raw optimizer state.
  
          strict: Whether to enforce that the keys in `state` match the keys in the checkpoint.
  
      Returns:
          The remaining items that were not restored into the given state dictionary. If no state dictionary is
          given, the full checkpoint will be returned.
  
      """
      torch.cuda.empty_cache()
      checkpoint = self.checkpoint_io.load_checkpoint(path)
      if not state:
          return checkpoint
  
      if isinstance(state, Module):
          self.load_module_state_dict(
              module=state, state_dict=checkpoint, strict=strict
          )
          return {}
  
      if isinstance(state, Optimizer):
          state.load_state_dict(checkpoint)
          return {}
  
      _validate_keys_for_strict_loading(
          state.keys(), checkpoint.keys(), strict=strict
      )
      for name, obj in state.copy().items():
          if name not in checkpoint:
              continue
          if isinstance(obj, _Stateful):
              if isinstance(obj, Module):
                  self.load_module_state_dict(
                      module=obj,
                      state_dict=checkpoint.pop(name),
                      strict=strict,
                  )
              else:
                  obj.load_state_dict(checkpoint.pop(name))
          else:
              state[name] = checkpoint.pop(name)
      return checkpoint
  
imports: import logging
  from abc import ABC, abstractmethod
  from contextlib import ExitStack
  from typing import Any, Callable, ContextManager, Dict, Iterable, List, Optional, Tuple, TypeVar, Union
  import torch
  from torch import Tensor
  from torch.nn import Module
  from torch.optim import Optimizer
  from torch.utils.data import DataLoader
  from lightning.fabric.accelerators import Accelerator
  from lightning.fabric.plugins.io.checkpoint_io import CheckpointIO
  from lightning.fabric.plugins.io.torch_io import TorchCheckpointIO
  from lightning.fabric.plugins.precision import Precision
  from lightning.fabric.strategies.launchers.launcher import _Launcher
  from lightning.fabric.strategies.registry import _StrategyRegistry
  from lightning.fabric.utilities.apply_func import move_data_to_device
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_1_13, _TORCH_GREATER_EQUAL_2_0
  from lightning.fabric.utilities.init import _EmptyInit
  from lightning.fabric.utilities.types import _PATH, Optimizable, ReduceOp, _Stateful
label_desc: Use image node_id 32 for calling the Strategy obj's underlying member method code with example usage: obj.load_checkpoint(path, state, strict) and returns: checkpoint, checkpoint, dict, dict