code: def ckpt_to_dir(filepath: Union[str, Path]) -> Path:
      """PTL considers checkpoints as .ckpt files.
      This method removes the extension and returns a path
      to be used as a directory for distributed checkpoints
      """
  
      filepath = Path(filepath)
  
      # if it is already a distributed checkpoint, then return
      if filepath.suffix != ".ckpt" and filepath.is_dir():
          return filepath
  
      # adding this assert because we will later remove directories based on the return value of this method
      assert (
          filepath.suffix == ".ckpt"
      ), f"filepath: {filepath} must have .ckpt extension"
  
      # create a new path whose name is the original filepath without the .ckpt extension
      checkpoint_dir = filepath.with_name(filepath.stem)
  
      return checkpoint_dir
  
imports: import copy
  import importlib
  import os
  from dataclasses import dataclass, is_dataclass
  from enum import Enum
  from functools import lru_cache
  from pathlib import Path
  from typing import List, Optional, Tuple, Union
  import wrapt
  from nemo.utils import AppState, logging
  from nemo.utils.data_utils import resolve_cache_dir
  from nemo.utils.data_utils import is_datastore_path
label_desc: Use image node_id 15 for calling a global function with example usage: ckpt_to_dir(filepath) and returns: checkpoint_dir, filepath