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 __init__(
      self,
      learned_embeddings_filename: str = "learned_embeddings_dict.pt",
      scheduler_name: Literal["ddim", "lms-discrete", "pndm"] = "pndm",
      beta_start: float = 0.00085,
      beta_end: float = 0.012,
      beta_schedule: Literal[
          "linear", "scaled_linear", "squaredcos_cap_v2"
      ] = "scaled_linear",
      other_scheduler_kwargs: Optional[Dict[str, Any]] = None,
      pretrained_model_name_or_path: str = "CompVis/stable-diffusion-v1-4",
      device: str = "cuda",
      use_fp16: bool = True,
      disable_progress_bar: bool = False,
  ) -> None:
      # We assume that the Huggingface User Access token has been stored as the HF_AUTH_TOKEN
      # environment variable. See https://huggingface.co/docs/hub/security-tokens
      try:
          self.use_auth_token = os.environ["HF_AUTH_TOKEN"]
      except KeyError:
          raise KeyError(
              "Please set your HF User Access token as the HF_AUTH_TOKEN environment variable."
          )
      self.learned_embeddings_filename = learned_embeddings_filename
      self.scheduler_name = scheduler_name
      self.beta_start = beta_start
      self.beta_end = beta_end
      self.beta_schedule = beta_schedule
      self.other_scheduler_kwargs = (
          other_scheduler_kwargs
          or defaults.DEFAULT_SCHEDULER_KWARGS_DICT[scheduler_name]
      )
      self.pretrained_model_name_or_path = pretrained_model_name_or_path
      self.device = device
      self.use_fp16 = use_fp16
      self.disable_progress_bar = disable_progress_bar
  
      scheduler_kwargs = {
          "beta_start": self.beta_start,
          "beta_end": self.beta_end,
          "beta_schedule": self.beta_schedule,
          **self.other_scheduler_kwargs,
      }
      self.scheduler = defaults.NOISE_SCHEDULER_DICT[
          self.scheduler_name
      ](**scheduler_kwargs)
  
      # The below attrs are non-trivially instantiated as necessary through appropriate methods.
      self.all_checkpoint_dirs = []
      self.learned_embeddings_dict = {}
      self.concept_to_dummy_tokens_map = {}
      self.all_added_concepts = []
  
      self.steps_completed = None
      self.num_generated_imgs = None
      self.image_history = []
  
      self._build_hf_pipeline(
          disable_progress_bar=self.disable_progress_bar
      )
  
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 1 to create a new DetSDTextualInversionPipeline object  with example: obj = DetSDTextualInversionPipeline(learned_embeddings_filename, scheduler_name, beta_start, beta_end, beta_schedule, other_scheduler_kwargs, pretrained_model_name_or_path, device, use_fp16, disable_progress_bar)