code: def _save_state_dict(
      detector: StateMixin, keys: tuple, filepath: Path
  ):
      """
      Utility function to save a detector's state dictionary to a filepath.
  
      Parameters
      ----------
      detector
          The detector to extract state attributes from.
      keys
          Tuple of state dict keys to populate dictionary with.
      filepath
          The file to save state dictionary to.
      """
      # Construct state dictionary
      state_dict = {key: getattr(detector, key, None) for key in keys}
      # Save to disk
      if filepath.suffix == ".pt":
          _save_state_dict_pt(state_dict, filepath)
      else:
          np.savez(filepath, **state_dict)
  
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 1 for calling a global function with example usage: _save_state_dict(detector, keys, filepath) without return types