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 _restore_latest_checkpoint(
      self,
      core_context: det.core.Context,
      latest_checkpoint: str,
      generator: torch.Generator,
      trial_id: int,
  ) -> None:
      with core_context.checkpoint.restore_path(
          latest_checkpoint
      ) as path:
          # Restore the state per the docs:
          # https://docs.determined.ai/latest/training/apis-howto/api-core/checkpoints.html
          with open(path.joinpath("metadata.json"), "r") as f:
              checkpoint_metadata_dict = json.load(f)
              if trial_id == checkpoint_metadata_dict["trial_id"]:
                  self.steps_completed = checkpoint_metadata_dict[
                      "steps_completed"
                  ]
              else:
                  self.steps_completed = 0
              generator_state_dict = torch.load(
                  path.joinpath("generator_state_dict.pt"),
              )
              self.num_generated_imgs = checkpoint_metadata_dict[
                  "num_generated_imgs"
              ]
              generator.set_state(generator_state_dict[self.device])
              self.image_history = torch.load(
                  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 10 for calling the DetSDTextualInversionPipeline obj's underlying member method code with example usage: obj._restore_latest_checkpoint(core_context, latest_checkpoint, generator, trial_id) without return types