class_docstr: Class for generating images from a Stable Diffusion checkpoint trained using Determined
  AI. Initialize with no arguments in order to run plain Stable Diffusion without any trained
  textual inversion embeddings. Can optionally be run on a Determined cluster through the
  .generate_on_cluster() method for large-scale generation. Only intended for use with a GPU.
code: def _save(
      self,
      core_context: det.core.Context,
      devices_and_generators: List[Tuple[str, torch.ByteTensor]],
      trial_id: int,
  ) -> None:
      checkpoint_metadata_dict = {
          "steps_completed": self.steps_completed,
          "num_generated_imgs": self.num_generated_imgs,
          "trial_id": trial_id,
      }
      with core_context.checkpoint.store_path(
          checkpoint_metadata_dict
      ) as (
          path,
          storage_id,
      ):
          generator_state_dict = {
              device: state for device, state in devices_and_generators
          }
          torch.save(
              generator_state_dict,
              path.joinpath("generator_state_dict.pt"),
          )
          torch.save(
              self.image_history,
              path.joinpath("self.image_history.pt"),
          )
  
imports: import json
  import logging
  import os
  import pathlib
  from typing import Any, Dict, List, Literal, Optional, Sequence, Tuple, Union
  import torch
  from detsd import defaults, utils
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipeline, StableDiffusionPipelineOutput
  from torch.utils.tensorboard import SummaryWriter
  from torchvision.transforms.functional import pil_to_tensor
  import determined
  from determined.experimental import client
label_desc: Use image node_id 11 for calling the DetSDTextualInversionPipeline obj's underlying member method code with example usage: obj._save(core_context, devices_and_generators, trial_id) without return types