class_docstr: Test Stable Diffusion text-to-image pipeline for:
  
  - PyTorch to CoreML conversion via coremltools
  - Speed of CoreML runtime across several compute units
  - Integration with `diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.py`
  - Efficacy of the safety_checker
  - Affinity of the generated image with the original prompt via CLIP score
  - The bridge between Python and Swift CLI
  - The signal parity of Swift CLI generated image with that of Python CLI
docstr: Tests:
  - Speed of CoreML runtime across several compute units
  - Integration with `diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.py`
docstr_tok: ["Tests",":","-","Speed","of","CoreML","runtime","across","several","compute","units","-","Integration","with","`","diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.py","`"]
code: def test_end_to_end_image_generation_speed(self):
      """Tests:
      - Speed of CoreML runtime across several compute units
      - Integration with `diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.py`
      """
      latency = {
          compute_unit: self._coreml_text_to_image_with_compute_unit(
              compute_unit
          )
          for compute_unit in TEST_COMPUTE_UNIT
      }
      latency[
          "num_repeats_for_median"
      ] = TEST_TEXT_TO_IMAGE_SPEED_REPEATS
  
      json_path = os.path.join(self.cli_args.o, "benchmark.json")
      logger.info(f"Saving inference benchmark results to {json_path}")
      with open(json_path, "w") as f:
          json.dump(latency, f)
  
      for compute_unit in TEST_COMPUTE_UNIT:
          with self.subTest(compute_unit=compute_unit):
              self.assertGreater(
                  TEST_ABSOLUTE_MAX_LATENCY, latency[compute_unit]
              )
  
imports: import argparse
  import contextlib
  import coremltools
  from diffusers import StableDiffusionPipeline
  import json
  import logging
  import numpy
  import os
  import unittest
  from PIL import Image
  from statistics import median
  import tempfile
  import time
  import torch
  from python_coreml_stable_diffusion import torch2coreml, pipeline, coreml_model
label_desc: Use image node_id 4 for calling the TestStableDiffusionForTextToImage obj's underlying member method code with example usage: obj.test_end_to_end_image_generation_speed() without return types