docstr: Called by the ``Trainer`` to select the checkpoint path source.
docstr_tok: ["Called","by","the","``","Trainer","``","to","select","the","checkpoint","path","source","."]
code: def _select_ckpt_path(
      self,
      state_fn: TrainerFn,
      ckpt_path: Optional[_PATH],
      model_provided: bool,
      model_connected: bool,
  ) -> Optional[_PATH]:
      """Called by the ``Trainer`` to select the checkpoint path source."""
      if self._user_managed:
          if ckpt_path:
              rank_zero_warn(
                  f"`trainer.ckpt_path = {self._ckpt_path!r}` was called but then you"
                  f" passed `trainer.fit(ckpt_path={ckpt_path!r})`. The latter will be loaded."
              )
              # reset the previous path
              self._ckpt_path = None
              self._user_managed = False
              ckpt_path = self._parse_ckpt_path(
                  state_fn,
                  ckpt_path,
                  model_provided=model_provided,
                  model_connected=model_connected,
              )
          else:
              ckpt_path = self._ckpt_path
      else:
          ckpt_path = self._parse_ckpt_path(
              state_fn,
              ckpt_path,
              model_provided=model_provided,
              model_connected=model_connected,
          )
      return ckpt_path
  
imports: import logging
  import os
  import re
  from typing import Any, Dict, Optional
  import torch
  from fsspec.core import url_to_fs
  from fsspec.implementations.local import LocalFileSystem
  from torch import Tensor
  import lightning.pytorch
  from lightning.fabric.plugins.environments.slurm import SLURMEnvironment
  from lightning.fabric.utilities.cloud_io import _is_dir, get_filesystem
  from lightning.fabric.utilities.types import _PATH
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.plugins.precision import MixedPrecision
  from lightning.pytorch.trainer import call
  from lightning.pytorch.trainer.states import TrainerFn
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _OMEGACONF_AVAILABLE
  from lightning.pytorch.utilities.migration import pl_legacy_patch
  from lightning.pytorch.utilities.migration.utils import _pl_migrate_checkpoint
  from lightning.pytorch.utilities.rank_zero import rank_zero_info, rank_zero_warn
label_desc: Use image node_id 4 for calling the _CheckpointConnector obj's underlying member method code with example usage: obj._select_ckpt_path(state_fn, ckpt_path, model_provided, model_connected) and returns: ckpt_path