class_docstr: A :class:`~ray.train.Checkpoint` with Torch-specific functionality.
class_docstr_tok: ["A",":","class",":","`","~ray.train.Checkpoint","`","with","Torch-specific","functionality","."]
docstr: Retrieve the model stored in this checkpoint.
  
  Args:
      model: If the checkpoint contains a model state dict, and not
          the model itself, then the state dict will be loaded to this
          ``model``. Otherwise, the model will be discarded.
docstr_tok: ["Retrieve","the","model","stored","in","this","checkpoint",".","Args",":","model",":","If","the","checkpoint","contains","a","model","state","dict",",","and","not","the","model","itself",",","then","the","state","dict","will","be","loaded","to","this","``","model","``",".","Otherwise",",","the","model","will","be","discarded","."]
code: def get_model(
      self, model: Optional[torch.nn.Module] = None
  ) -> torch.nn.Module:
      """Retrieve the model stored in this checkpoint.
  
      Args:
          model: If the checkpoint contains a model state dict, and not
              the model itself, then the state dict will be loaded to this
              ``model``. Otherwise, the model will be discarded.
      """
      with self.as_directory() as tempdir:
          model_path = os.path.join(tempdir, self.MODEL_FILENAME)
          if not os.path.exists(model_path):
              raise RuntimeError(
                  "`model.pt` not found within this checkpoint. Make sure you "
                  "created this `TorchCheckpoint` from one of its public "
                  "constructors (`from_state_dict` or `from_model`)."
              )
          model_or_state_dict = torch.load(
              model_path, map_location="cpu"
          )
  
      if isinstance(model_or_state_dict, torch.nn.Module):
          if model:
              warnings.warn(
                  "TorchCheckpoint already contains all information needed. "
                  "Discarding provided `model` argument. This means: "
                  "If you are using BatchPredictor, you should do "
                  "`BatchPredictor.from_checkpoint(checkpoint, TorchPredictor)` by"
                  "removing kwargs `model=`. "
                  "If you are using TorchPredictor directly, you should do "
                  "`TorchPredictor.from_checkpoint(checkpoint)` by removing kwargs "
                  "`model=`."
              )
      model = load_torch_model(
          saved_model=model_or_state_dict, model_definition=model
      )
      return model
  
file_path: ray/python/ray/train/torch/torch_checkpoint.py
imports: import os
  import tempfile
  import warnings
  from typing import TYPE_CHECKING, Any, Dict, Optional
  import torch
  from ray.air._internal.torch_utils import consume_prefix_in_state_dict_if_present_not_in_place, load_torch_model
  from ray.train._internal.framework_checkpoint import FrameworkCheckpoint
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 3 for calling the TorchCheckpoint obj's underlying member method code with example usage: obj.get_model(model) and returns: model