code: def test_pipeline_interrupt(self):
      components = self.get_dummy_components()
      sd_pipe = StableDiffusionXLInpaintPipeline(**components)
      sd_pipe = sd_pipe.to(torch_device)
      sd_pipe.set_progress_bar_config(disable=None)
  
      inputs = self.get_dummy_inputs(torch_device)
  
      prompt = "hey"
      num_inference_steps = 5
  
      # store intermediate latents from the generation process
      class PipelineState:
          def __init__(self):
              self.state = []
  
          def apply(self, pipe, i, t, callback_kwargs):
              self.state.append(callback_kwargs["latents"])
              return callback_kwargs
  
      pipe_state = PipelineState()
      sd_pipe(
          prompt,
          image=inputs["image"],
          mask_image=inputs["mask_image"],
          strength=0.8,
          num_inference_steps=num_inference_steps,
          output_type="np",
          generator=torch.Generator("cpu").manual_seed(0),
          callback_on_step_end=pipe_state.apply,
      ).images
  
      # interrupt generation at step index
      interrupt_step_idx = 1
  
      def callback_on_step_end(pipe, i, t, callback_kwargs):
          if i == interrupt_step_idx:
              pipe._interrupt = True
  
          return callback_kwargs
  
      output_interrupted = sd_pipe(
          prompt,
          image=inputs["image"],
          mask_image=inputs["mask_image"],
          strength=0.8,
          num_inference_steps=num_inference_steps,
          output_type="latent",
          generator=torch.Generator("cpu").manual_seed(0),
          callback_on_step_end=callback_on_step_end,
      ).images
  
      # fetch intermediate latents at the interrupted step
      # from the completed generation process
      intermediate_latent = pipe_state.state[interrupt_step_idx]
  
      # compare the intermediate latent to the output of the interrupted process
      # they should be the same
      assert torch.allclose(
          intermediate_latent, output_interrupted, atol=1e-4
      )
  
imports: import copy
  import random
  import unittest
  import numpy
  import torch
  from PIL import Image
  from transformers import CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection
  from diffusers import AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, EulerDiscreteScheduler, HeunDiscreteScheduler, LCMScheduler, StableDiffusionXLInpaintPipeline, UNet2DConditionModel, UniPCMultistepScheduler
  from diffusers.utils.testing_utils import enable_full_determinism, floats_tensor, require_torch_gpu, slow, torch_device
  from ..pipeline_params import TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS, TEXT_GUIDED_IMAGE_INPAINTING_PARAMS, TEXT_TO_IMAGE_CALLBACK_CFG_PARAMS
  from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin
label_desc: Use image node_id 21 for calling the StableDiffusionXLInpaintPipelineFastTests obj's underlying member method code with example usage: obj.test_pipeline_interrupt() and returns: callback_kwargs, callback_kwargs