code: def test_text_to_image_lora_checkpointing_checkpoints_total_limit(
      self,
  ):
      pretrained_model_name_or_path = (
          "hf-internal-testing/tiny-stable-diffusion-pipe"
      )
      prompt = "a prompt"
  
      with tempfile.TemporaryDirectory() as tmpdir:
          # Run training script with checkpointing
          # max_train_steps == 7, checkpointing_steps == 2, checkpoints_total_limit == 2
          # Should create checkpoints at steps 2, 4, 6
          # with checkpoint at step 2 deleted
  
          initial_run_args = f"""
                  examples/text_to_image/train_text_to_image_lora.py
                  --pretrained_model_name_or_path {pretrained_model_name_or_path}
                  --dataset_name hf-internal-testing/dummy_image_text_data
                  --resolution 64
                  --center_crop
                  --random_flip
                  --train_batch_size 1
                  --gradient_accumulation_steps 1
                  --max_train_steps 7
                  --learning_rate 5.0e-04
                  --scale_lr
                  --lr_scheduler constant
                  --lr_warmup_steps 0
                  --output_dir {tmpdir}
                  --checkpointing_steps=2
                  --checkpoints_total_limit=2
                  --seed=0
                  --num_validation_images=0
                  """.split()
  
          run_command(self._launch_args + initial_run_args)
  
          pipe = DiffusionPipeline.from_pretrained(
              "hf-internal-testing/tiny-stable-diffusion-pipe",
              safety_checker=None,
          )
          pipe.load_lora_weights(tmpdir)
          pipe(prompt, num_inference_steps=2)
  
          # check checkpoint directories exist
          self.assertEqual(
              {x for x in os.listdir(tmpdir) if "checkpoint" in x},
              # checkpoint-2 should have been deleted
              {"checkpoint-4", "checkpoint-6"},
          )
  
imports: import logging
  import os
  import shutil
  import subprocess
  import sys
  import tempfile
  import unittest
  from typing import List
  import safetensors
  from accelerate.utils import write_basic_config
  from diffusers import DiffusionPipeline, UNet2DConditionModel
label_desc: Use image node_id 22 for calling the ExamplesTestsAccelerate obj's underlying member method code with example usage: obj.test_text_to_image_lora_checkpointing_checkpoints_total_limit() without return types