class_docstr: Utility class that provides methods to save and load stateful attributes to disk.
docstr: Save a detector's state to disk in order to generate a checkpoint.
  
  Parameters
  ----------
  filepath
      The directory to save state to.
docstr_tok: ["Save","a","detector","'s","state","to","disk","in","order","to","generate","a","checkpoint",".","Parameters","--","--","--","--","--","filepath","The","directory","to","save","state","to","."]
code: def save_state(self, filepath: Union[str, os.PathLike]):
      """
      Save a detector's state to disk in order to generate a checkpoint.
  
      Parameters
      ----------
      filepath
          The directory to save state to.
      """
      self._set_state_dir(filepath)
      suffix = (
          ".pt"
          if hasattr(self, "backend")
          and self.backend == Framework.PYTORCH
          else ".npz"
      )
      _save_state_dict(
          self,
          self.online_state_keys,
          self.state_dir.joinpath("state" + suffix),
      )
      logger.info(
          "Saved state for t={} to {}".format(self.t, self.state_dir)
      )
  
file_path: alibi-detect/alibi_detect/utils/state/state.py
imports: import os
  from pathlib import Path
  import logging
  from abc import ABC
  from typing import Union, Tuple
  import numpy
  from alibi_detect.utils.frameworks import Framework
  from alibi_detect.utils.state._pytorch import save_state_dict, load_state_dict
label_desc: Use image node_id 2 for calling the StateMixin obj's underlying member method code with example usage: obj.save_state(filepath) without return types