docstr: Save model, optimizer, and other state in a checkpoint directory.
  
  Args:
      path: A path to where the files should be saved
      state: A dictionary with contents to be saved. If the dict contains modules or optimizers, their
          state-dict will be retrieved and converted automatically.
      storage_options: Unused by this strategy, since it doesn't use a ``CheckpointIO`` plugin.
      filter: Unsupported.
  
  Raises:
      TypeError:
          If the unused ``storage_options`` gets passed.
      ValueError:
          When no :class:`deepspeed.DeepSpeedEngine` objects were found in the state, or when multiple
          :class:`deepspeed.DeepSpeedEngine` objects were found.
docstr_tok: ["Save","model",",","optimizer",",","and","other","state","in","a","checkpoint","directory",".","Args",":","path",":","A","path","to","where","the","files","should","be","saved","state",":","A","dictionary","with","contents","to","be","saved",".","If","the","dict","contains","modules","or","optimizers",",","their","state-dict","will","be","retrieved","and","converted","automatically",".","storage_options",":","Unused","by","this","strategy",",","since","it","does","n't","use","a","``","CheckpointIO","``","plugin",".","filter",":","Unsupported",".","Raises",":","TypeError",":","If","the","unused","``","storage_options","``","gets","passed",".","ValueError",":","When","no",":","class",":","`","deepspeed.DeepSpeedEngine","`","objects","were","found","in","the","state",",","or","when","multiple",":","class",":","`","deepspeed.DeepSpeedEngine","`","objects","were","found","."]
code: def save_checkpoint(
      self,
      path: _PATH,
      state: Dict[str, Union[Module, Optimizer, Any]],
      storage_options: Optional[Any] = None,
      filter: Optional[Dict[str, Callable[[str, Any], bool]]] = None,
  ) -> None:
      """Save model, optimizer, and other state in a checkpoint directory.
  
      Args:
          path: A path to where the files should be saved
          state: A dictionary with contents to be saved. If the dict contains modules or optimizers, their
              state-dict will be retrieved and converted automatically.
          storage_options: Unused by this strategy, since it doesn't use a ``CheckpointIO`` plugin.
          filter: Unsupported.
  
      Raises:
          TypeError:
              If the unused ``storage_options`` gets passed.
          ValueError:
              When no :class:`deepspeed.DeepSpeedEngine` objects were found in the state, or when multiple
              :class:`deepspeed.DeepSpeedEngine` objects were found.
  
      """
      if storage_options is not None:
          raise TypeError(
              "`DeepSpeedStrategy.save_checkpoint(..., storage_options=...)` is not supported because"
              " `DeepSpeedStrategy` does not use the `CheckpointIO`."
          )
      if filter is not None:
          raise TypeError(
              "`DeepSpeedStrategy.save_checkpoint(..., filter=...)` is not supported because"
              " `DeepSpeedStrategy` manages the state serialization internally."
          )
  
      engines = _get_deepspeed_engines_from_state(state)
      if len(engines) == 0:
          raise ValueError(
              "Could not find a DeepSpeed model in the provided checkpoint state. Please provide the model as"
              " part of the state like so: `save_checkpoint(..., state={'model': model, ...})`. Make sure"
              " you set up the model (and optimizers if any) through the strategy before saving the checkpoint."
          )
      if len(engines) > 1:
          raise ValueError(
              "Found multiple DeepSpeed engine modules in the given state. Saving checkpoints with DeepSpeed is"
              " currently limited to a single model per checkpoint. To save multiple models, call the"
              " save method for each model separately with a different path."
          )
      engine = engines[0]
  
      # broadcast the path from rank 0 to ensure all the states are saved in a common path
      path = self.broadcast(path)
  
      # split the checkpoint into two parts:
      # 1) the deepspeed engine encapsulating both the model and optionally the optimizer(s)
      # 2) the rest of the user's state, which in deepspeed is called `client state`
      excluded_objects = (
          (engine, engine.optimizer)
          if engine.optimizer is not None
          else (engine,)
      )
      state = {
          k: v for k, v in state.items() if v not in excluded_objects
      }
      _validate_state_keys(state)
      # there might be other stateful objects unrelated to the deepspeed engine - convert them to a state_dict
      state = self._convert_stateful_objects_in_state(state, filter={})
      # use deepspeed's internal checkpointing function to handle partitioned weights across processes
      engine.save_checkpoint(path, client_state=state, tag="checkpoint")
  
imports: import argparse
  import json
  import logging
  import os
  import platform
  from contextlib import ExitStack
  from itertools import chain
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Callable, ContextManager, Dict, List, Mapping, Optional, Tuple, Union
  import torch
  from lightning_utilities.core.imports import RequirementCache
  from torch.nn import Module
  from torch.optim import Optimizer
  from typing_extensions import override
  from lightning.fabric.accelerators import Accelerator, CUDAAccelerator
  from lightning.fabric.plugins.environments.cluster_environment import ClusterEnvironment
  from lightning.fabric.plugins.precision import Precision
  from lightning.fabric.strategies.ddp import DDPStrategy
  from lightning.fabric.strategies.registry import _StrategyRegistry
  from lightning.fabric.strategies.strategy import _Sharded
  from lightning.fabric.utilities.distributed import log
  from lightning.fabric.utilities.load import _move_state_into
  from lightning.fabric.utilities.rank_zero import rank_zero_info, rank_zero_warn
  from lightning.fabric.utilities.seed import reset_seed
  from lightning.fabric.utilities.types import _PATH
label_desc: Use image node_id 10 for calling the DeepSpeedStrategy obj's underlying member method code with example usage: obj.save_checkpoint(path, state, storage_options, filter) without return types