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 _write_tb_imgs(
      self,
      core_context: det.core.Context,
      tb_writer: SummaryWriter,
      tb_tag: str,
  ) -> None:
      for idx, img in enumerate(self.image_history):
          img_t = pil_to_tensor(img)
          global_step = self.num_generated_imgs + idx
          tb_writer.add_image(
              tb_tag,
              img_tensor=img_t,
              global_step=global_step,
          )
      tb_writer.flush()
      core_context.train.upload_tensorboard_files()
      self.num_generated_imgs += len(self.image_history)
      self.image_history = []
  
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 9 for calling the DetSDTextualInversionPipeline obj's underlying member method code with example usage: obj._write_tb_imgs(core_context, tb_writer, tb_tag) without return types