




import json
import unittest

import numpy as np
from huggingface_hub import hf_hub_download

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
	import torch

	if is_vision_available():
		from transformers import OneFormerImageProcessor
		from transformers.models.oneformer.image_processing_oneformer import binary_mask_to_rle
		from transformers.models.oneformer.modeling_oneformer import OneFormerForUniversalSegmentationOutput

if is_vision_available():
	from PIL import Image



def        __a							(  __UpperCAmelCase		:						int   ,		__UpperCAmelCase		:						Optional[int]="shi-labs/oneformer_demo"      ) ->					Any:
							"""simple docstring"""




							with open(hf_hub_download(__UpperCAmelCase   ,		__UpperCAmelCase   ,		repo_type="dataset"      )   ,		"r"      ) as f:
														lowerCamelCase_			:    int   						=      json.load(__UpperCAmelCase      )
							lowerCamelCase_			:    List[str]   						=      {}
							lowerCamelCase_			:    Optional[Any]   						=      []
							lowerCamelCase_			:    Optional[Any]   						=      []
							for key, info in class_info.items():
														lowerCamelCase_			:    int   						=      info["name"]
														class_names.append(info["name"]      )
														if info["isthing"]:
																					thing_ids.append(int(__UpperCAmelCase      )      )
							lowerCamelCase_			:    str   						=      thing_ids
							lowerCamelCase_			:    Dict   						=      class_names
							return metadata





class 					snake_case_   (     unittest.TestCase	):



				'''simple docstring'''





				def __init__(      self							:   List[str]      ,							__magic_name__							:   List[Any]      ,							__magic_name__							:   str=7      ,							__magic_name__							:   Any=3      ,							__magic_name__							:   int=30      ,							__magic_name__							:   List[str]=400      ,							__magic_name__							:   Dict=None      ,							__magic_name__							:   Tuple=True      ,							__magic_name__							:   int=True      ,							__magic_name__							:   List[str]=[0.5, 0.5, 0.5]      ,							__magic_name__							:   Optional[Any]=[0.5, 0.5, 0.5]      ,							__magic_name__							:   Union[str, Any]=10      ,							__magic_name__							:   Any=False      ,							__magic_name__							:   Optional[int]=255      ,							__magic_name__							:   Dict="shi-labs/oneformer_demo"      ,							__magic_name__							:   Optional[int]="ade20k_panoptic.json"      ,							__magic_name__							:   int=10      ,							)							->			Optional[int]:
											lowerCamelCase_			:    Dict   						=      parent
											lowerCamelCase_			:    List[str]   						=      batch_size
											lowerCamelCase_			:    int   						=      num_channels
											lowerCamelCase_			:    List[Any]   						=      min_resolution
											lowerCamelCase_			:    int   						=      max_resolution
											lowerCamelCase_			:    str   						=      do_resize
											lowerCamelCase_			:    Optional[int]   						=      {"shortest_edge": 32, "longest_edge": 1333} if size is None else size
											lowerCamelCase_			:    Dict   						=      do_normalize
											lowerCamelCase_			:    str   						=      image_mean
											lowerCamelCase_			:    Optional[Any]   						=      image_std
											lowerCamelCase_			:    Tuple   						=      class_info_file
											lowerCamelCase_			:    Tuple   						=      prepare_metadata(__magic_name__      ,							__magic_name__							)
											lowerCamelCase_			:    Any   						=      num_text
											lowerCamelCase_			:    Optional[Any]   						=      repo_path

											# for the post_process_functions
											lowerCamelCase_			:    Tuple   						=      2
											lowerCamelCase_			:    Union[str, Any]   						=      10
											lowerCamelCase_			:    Union[str, Any]   						=      10
											lowerCamelCase_			:    Tuple   						=      3
											lowerCamelCase_			:    Optional[Any]   						=      4
											lowerCamelCase_			:    List[str]   						=      num_labels
											lowerCamelCase_			:    int   						=      do_reduce_labels
											lowerCamelCase_			:    int   						=      ignore_index





				def    __SCREAMING_SNAKE_CASE     (      self							:   Union[str, Any]							)							->			Optional[int]:
											return {
											    "do_resize": self.do_resize,
											    "size": self.size,
											    "do_normalize": self.do_normalize,
											    "image_mean": self.image_mean,
											    "image_std": self.image_std,
											    "num_labels": self.num_labels,
											    "do_reduce_labels": self.do_reduce_labels,
											    "ignore_index": self.ignore_index,
											    "class_info_file": self.class_info_file,
											    "metadata": self.metadata,
											    "num_text": self.num_text,
											}





				def    __SCREAMING_SNAKE_CASE     (      self							:   Dict      ,							__magic_name__							:   int      ,							__magic_name__							:   Optional[Any]=False							)							->			List[Any]:





											if not batched:
																		lowerCamelCase_			:    Optional[int]   						=      image_inputs[0]
																		if isinstance(__magic_name__      ,							Image.Image							):
																									lowerCamelCase_			:    str   						=      image.size
																		else:
																									lowerCamelCase_			:    str   						=      image.shape[1], image.shape[2]
																		if w < h:
																									lowerCamelCase_			:    Optional[int]   						=      int(self.size["shortest_edge"] * h / w							)
																									lowerCamelCase_			:    Union[str, Any]   						=      self.size["shortest_edge"]
																		elif w > h:
																									lowerCamelCase_			:    List[str]   						=      self.size["shortest_edge"]
																									lowerCamelCase_			:    Dict   						=      int(self.size["shortest_edge"] * w / h							)
																		else:
																									lowerCamelCase_			:    int   						=      self.size["shortest_edge"]
																									lowerCamelCase_			:    Dict   						=      self.size["shortest_edge"]

											else:
																		lowerCamelCase_			:    Optional[Any]   						=      []
																		for image in image_inputs:
																									lowerCamelCase_			:    Dict   						=      self.get_expected_values([image]							)
																									expected_values.append((expected_height, expected_width)							)
																		lowerCamelCase_			:    Optional[Any]   						=      max(__magic_name__      ,							key=lambda __magic_name__							: item[0]							)[0]
																		lowerCamelCase_			:    Any   						=      max(__magic_name__      ,							key=lambda __magic_name__							: item[1]							)[1]

											return expected_height, expected_width





				def    __SCREAMING_SNAKE_CASE     (      self							:   Optional[Any]							)							->			str:
											return OneFormerForUniversalSegmentationOutput(
											    # +1 for null class
											    class_queries_logits=torch.randn((self.batch_size, self.num_queries, self.num_classes + 1)							)      ,							masks_queries_logits=torch.randn((self.batch_size, self.num_queries, self.height, self.width)							)      ,							)





@require_torch
@require_vision
class 					snake_case_   (     _UpperCamelCase   ,	unittest.TestCase	):



				'''simple docstring'''
				lowerCamelCase       =  OneFormerImageProcessor if (is_vision_available() and is_torch_available()) else None
				# only for test_image_processing_common.test_image_proc_to_json_string
				lowerCamelCase       =  image_processing_class





				def    __SCREAMING_SNAKE_CASE     (      self							:   Tuple							)							->			Optional[Any]:
											lowerCamelCase_			:    Optional[int]   						=      OneFormerImageProcessorTester(self							)





				@property
				def    __SCREAMING_SNAKE_CASE     (      self							:   Optional[Any]							)							->			Tuple:
											return self.image_processing_tester.prepare_image_processor_dict()





				def    __SCREAMING_SNAKE_CASE     (      self							:   str							)							->			Union[str, Any]:
											lowerCamelCase_			:    Union[str, Any]   						=      self.image_processing_class(**self.image_processor_dict							)
											self.assertTrue(hasattr(__magic_name__      ,							"image_mean"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"image_std"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"do_normalize"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"do_resize"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"size"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"ignore_index"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"class_info_file"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"num_text"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"repo_path"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"metadata"							)							)
											self.assertTrue(hasattr(__magic_name__      ,							"do_reduce_labels"							)							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   int							)							->			Optional[int]:
											pass





				def    __SCREAMING_SNAKE_CASE     (      self							:   Optional[int]							)							->			Optional[int]:
											lowerCamelCase_			:    str   						=      self.image_processing_class(**self.image_processor_dict							)
											# create random PIL images
											lowerCamelCase_			:    Optional[Any]   						=      prepare_image_inputs(self.image_processing_tester      ,							equal_resolution=__magic_name__							)
											for image in image_inputs:
																		self.assertIsInstance(__magic_name__      ,							Image.Image							)

											# Test not batched input
											lowerCamelCase_			:    Any   						=      image_processor(image_inputs[0]      ,							["semantic"]      ,							return_tensors="pt"							).pixel_values

											lowerCamelCase_			:    List[str]   						=      self.image_processing_tester.get_expected_values(__magic_name__							)

											self.assertEqual(
											    encoded_images.shape      ,							(1, self.image_processing_tester.num_channels, expected_height, expected_width)      ,							)

											# Test batched
											lowerCamelCase_			:    int   						=      self.image_processing_tester.get_expected_values(__magic_name__      ,							batched=__magic_name__							)

											lowerCamelCase_			:    List[str]   						=      image_processor(
											    __magic_name__      ,							["semantic"] * len(__magic_name__							)      ,							return_tensors="pt"							).pixel_values
											self.assertEqual(
											    encoded_images.shape      ,							(
											        self.image_processing_tester.batch_size,
											        self.image_processing_tester.num_channels,
											        expected_height,
											        expected_width,
											    )      ,							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   Tuple							)							->			Tuple:
											lowerCamelCase_			:    List[str]   						=      self.image_processing_class(**self.image_processor_dict							)
											# create random numpy tensors
											lowerCamelCase_			:    Union[str, Any]   						=      prepare_image_inputs(self.image_processing_tester      ,							equal_resolution=__magic_name__      ,							numpify=__magic_name__							)
											for image in image_inputs:
																		self.assertIsInstance(__magic_name__      ,							np.ndarray							)

											# Test not batched input
											lowerCamelCase_			:    List[str]   						=      image_processor(image_inputs[0]      ,							["semantic"]      ,							return_tensors="pt"							).pixel_values

											lowerCamelCase_			:    List[Any]   						=      self.image_processing_tester.get_expected_values(__magic_name__							)

											self.assertEqual(
											    encoded_images.shape      ,							(1, self.image_processing_tester.num_channels, expected_height, expected_width)      ,							)

											# Test batched
											lowerCamelCase_			:    Union[str, Any]   						=      self.image_processing_tester.get_expected_values(__magic_name__      ,							batched=__magic_name__							)

											lowerCamelCase_			:    str   						=      image_processor(
											    __magic_name__      ,							["semantic"] * len(__magic_name__							)      ,							return_tensors="pt"							).pixel_values
											self.assertEqual(
											    encoded_images.shape      ,							(
											        self.image_processing_tester.batch_size,
											        self.image_processing_tester.num_channels,
											        expected_height,
											        expected_width,
											    )      ,							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   List[Any]							)							->			Optional[int]:
											lowerCamelCase_			:    Dict   						=      self.image_processing_class(**self.image_processor_dict							)
											# create random PyTorch tensors
											lowerCamelCase_			:    List[Any]   						=      prepare_image_inputs(self.image_processing_tester      ,							equal_resolution=__magic_name__      ,							torchify=__magic_name__							)
											for image in image_inputs:
																		self.assertIsInstance(__magic_name__      ,							torch.Tensor							)

											# Test not batched input
											lowerCamelCase_			:    Any   						=      image_processor(image_inputs[0]      ,							["semantic"]      ,							return_tensors="pt"							).pixel_values

											lowerCamelCase_			:    Union[str, Any]   						=      self.image_processing_tester.get_expected_values(__magic_name__							)

											self.assertEqual(
											    encoded_images.shape      ,							(1, self.image_processing_tester.num_channels, expected_height, expected_width)      ,							)

											# Test batched
											lowerCamelCase_			:    List[str]   						=      self.image_processing_tester.get_expected_values(__magic_name__      ,							batched=__magic_name__							)

											lowerCamelCase_			:    Tuple   						=      image_processor(
											    __magic_name__      ,							["semantic"] * len(__magic_name__							)      ,							return_tensors="pt"							).pixel_values
											self.assertEqual(
											    encoded_images.shape      ,							(
											        self.image_processing_tester.batch_size,
											        self.image_processing_tester.num_channels,
											        expected_height,
											        expected_width,
											    )      ,							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   Optional[Any]      ,							__magic_name__							:   List[str]=False      ,							__magic_name__							:   Optional[Any]=False      ,							__magic_name__							:   Dict="np"							)							->			Optional[Any]:
											lowerCamelCase_			:    Optional[int]   						=      self.image_processing_class(**self.image_processor_dict							)
											# prepare image and target
											lowerCamelCase_			:    Union[str, Any]   						=      self.image_processing_tester.num_labels
											lowerCamelCase_			:    Optional[Any]   						=      None
											lowerCamelCase_			:    str   						=      None
											lowerCamelCase_			:    Union[str, Any]   						=      prepare_image_inputs(self.image_processing_tester      ,							equal_resolution=__magic_name__							)
											if with_segmentation_maps:
																		lowerCamelCase_			:    Any   						=      num_labels
																		if is_instance_map:
																									lowerCamelCase_			:    Optional[Any]   						=      list(range(__magic_name__							)							) * 2
																									lowerCamelCase_			:    Tuple   						=      dict(enumerate(__magic_name__							)							)
																		lowerCamelCase_			:    Optional[int]   						=      [
																		    np.random.randint(0      ,							high * 2      ,							(img.size[1], img.size[0])							).astype(np.uinta							) for img in image_inputs
																		]
																		if segmentation_type == "pil":
																									lowerCamelCase_			:    Tuple   						=      [Image.fromarray(__magic_name__							) for annotation in annotations]

											lowerCamelCase_			:    List[str]   						=      image_processor(
											    __magic_name__      ,							["semantic"] * len(__magic_name__							)      ,							__magic_name__      ,							return_tensors="pt"      ,							instance_id_to_semantic_id=__magic_name__      ,							pad_and_return_pixel_mask=__magic_name__      ,							)

											return inputs





				def    __SCREAMING_SNAKE_CASE     (      self							:   Union[str, Any]							)							->			Union[str, Any]:
											pass





				def    __SCREAMING_SNAKE_CASE     (      self							:   Dict							)							->			Optional[Any]:





											def common(__magic_name__							:   Tuple=False      ,							__magic_name__							:   str=None							):
																		lowerCamelCase_			:    Union[str, Any]   						=      self.comm_get_image_processor_inputs(
																		    with_segmentation_maps=__magic_name__      ,							is_instance_map=__magic_name__      ,							segmentation_type=__magic_name__							)

																		lowerCamelCase_			:    str   						=      inputs["mask_labels"]
																		lowerCamelCase_			:    str   						=      inputs["class_labels"]
																		lowerCamelCase_			:    Dict   						=      inputs["pixel_values"]
																		lowerCamelCase_			:    List[Any]   						=      inputs["text_inputs"]

																		# check the batch_size
																		for mask_label, class_label, text_input in zip(__magic_name__      ,							__magic_name__      ,							__magic_name__							):
																									self.assertEqual(mask_label.shape[0]      ,							class_label.shape[0]							)
																									# this ensure padding has happened
																									self.assertEqual(mask_label.shape[1:]      ,							pixel_values.shape[2:]							)
																									self.assertEqual(len(__magic_name__							)      ,							self.image_processing_tester.num_text							)

											common()
											common(is_instance_map=__magic_name__							)
											common(is_instance_map=__magic_name__      ,							segmentation_type="pil"							)
											common(is_instance_map=__magic_name__      ,							segmentation_type="pil"							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   Dict							)							->			Dict:
											lowerCamelCase_			:    str   						=      np.zeros((20, 50)							)
											lowerCamelCase_			:    Optional[Any]   						=      1
											lowerCamelCase_			:    Optional[Any]   						=      1
											lowerCamelCase_			:    Tuple   						=      1

											lowerCamelCase_			:    Optional[int]   						=      binary_mask_to_rle(__magic_name__							)
											self.assertEqual(len(__magic_name__							)      ,							4							)
											self.assertEqual(rle[0]      ,							21							)
											self.assertEqual(rle[1]      ,							45							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   Any							)							->			Dict:
											lowerCamelCase_			:    Optional[int]   						=      self.image_processing_class(
											    num_labels=self.image_processing_tester.num_classes      ,							max_seq_length=77      ,							task_seq_length=77      ,							class_info_file="ade20k_panoptic.json"      ,							num_text=self.image_processing_tester.num_text      ,							repo_path="shi-labs/oneformer_demo"      ,							)
											lowerCamelCase_			:    Dict   						=      self.image_processing_tester.get_fake_oneformer_outputs()

											lowerCamelCase_			:    Union[str, Any]   						=      fature_extractor.post_process_semantic_segmentation(__magic_name__							)

											self.assertEqual(len(__magic_name__							)      ,							self.image_processing_tester.batch_size							)
											self.assertEqual(
											    segmentation[0].shape      ,							(
											        self.image_processing_tester.height,
											        self.image_processing_tester.width,
											    )      ,							)

											lowerCamelCase_			:    Tuple   						=      [(1, 4) for i in range(self.image_processing_tester.batch_size							)]
											lowerCamelCase_			:    Optional[Any]   						=      fature_extractor.post_process_semantic_segmentation(__magic_name__      ,							target_sizes=__magic_name__							)

											self.assertEqual(segmentation[0].shape      ,							target_sizes[0]							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   int							)							->			Union[str, Any]:
											lowerCamelCase_			:    Optional[int]   						=      self.image_processing_class(
											    num_labels=self.image_processing_tester.num_classes      ,							max_seq_length=77      ,							task_seq_length=77      ,							class_info_file="ade20k_panoptic.json"      ,							num_text=self.image_processing_tester.num_text      ,							repo_path="shi-labs/oneformer_demo"      ,							)
											lowerCamelCase_			:    int   						=      self.image_processing_tester.get_fake_oneformer_outputs()
											lowerCamelCase_			:    int   						=      image_processor.post_process_instance_segmentation(__magic_name__      ,							threshold=0							)

											self.assertTrue(len(__magic_name__							) == self.image_processing_tester.batch_size							)
											for el in segmentation:
																		self.assertTrue("segmentation" in el							)
																		self.assertTrue("segments_info" in el							)
																		self.assertEqual(type(el["segments_info"]							)      ,							__magic_name__							)
																		self.assertEqual(
																		    el["segmentation"].shape      ,							(self.image_processing_tester.height, self.image_processing_tester.width)							)





				def    __SCREAMING_SNAKE_CASE     (      self							:   Optional[int]							)							->			Tuple:
											lowerCamelCase_			:    int   						=      self.image_processing_class(
											    num_labels=self.image_processing_tester.num_classes      ,							max_seq_length=77      ,							task_seq_length=77      ,							class_info_file="ade20k_panoptic.json"      ,							num_text=self.image_processing_tester.num_text      ,							repo_path="shi-labs/oneformer_demo"      ,							)
											lowerCamelCase_			:    Optional[int]   						=      self.image_processing_tester.get_fake_oneformer_outputs()
											lowerCamelCase_			:    str   						=      image_processor.post_process_panoptic_segmentation(__magic_name__      ,							threshold=0							)

											self.assertTrue(len(__magic_name__							) == self.image_processing_tester.batch_size							)
											for el in segmentation:
																		self.assertTrue("segmentation" in el							)
																		self.assertTrue("segments_info" in el							)
																		self.assertEqual(type(el["segments_info"]							)      ,							__magic_name__							)
																		self.assertEqual(
																		    el["segmentation"].shape      ,							(self.image_processing_tester.height, self.image_processing_tester.width)							)








from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import (
    BaseOutput,
    OptionalDependencyNotAvailable,
    is_flax_available,
    is_k_diffusion_available,
    is_k_diffusion_version,
    is_onnx_available,
    is_torch_available,
    is_transformers_available,
    is_transformers_version,
)







@dataclass
class 	__lowerCAmelCase      (       _UpperCamelCase	):
   _UpperCamelCase			:    Union[List[PIL.Image.Image], np.ndarray]
   _UpperCamelCase			:    Optional[List[bool]]


try:
  if not (is_transformers_available() and is_torch_available()):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_torch_and_transformers_objects import *  # noqa F403
else:
  from .pipeline_cycle_diffusion import CycleDiffusionPipeline
  from .pipeline_stable_diffusion import StableDiffusionPipeline
  from .pipeline_stable_diffusion_attend_and_excite import StableDiffusionAttendAndExcitePipeline
  from .pipeline_stable_diffusion_imgaimg import StableDiffusionImgaImgPipeline
  from .pipeline_stable_diffusion_inpaint import StableDiffusionInpaintPipeline
  from .pipeline_stable_diffusion_inpaint_legacy import StableDiffusionInpaintPipelineLegacy
  from .pipeline_stable_diffusion_instruct_pixapix import StableDiffusionInstructPixaPixPipeline
  from .pipeline_stable_diffusion_latent_upscale import StableDiffusionLatentUpscalePipeline
  from .pipeline_stable_diffusion_ldmad import StableDiffusionLDMaDPipeline
  from .pipeline_stable_diffusion_model_editing import StableDiffusionModelEditingPipeline
  from .pipeline_stable_diffusion_panorama import StableDiffusionPanoramaPipeline
  from .pipeline_stable_diffusion_paradigms import StableDiffusionParadigmsPipeline
  from .pipeline_stable_diffusion_sag import StableDiffusionSAGPipeline
  from .pipeline_stable_diffusion_upscale import StableDiffusionUpscalePipeline
  from .pipeline_stable_unclip import StableUnCLIPPipeline
  from .pipeline_stable_unclip_imgaimg import StableUnCLIPImgaImgPipeline
  from .safety_checker import StableDiffusionSafetyChecker
  from .stable_unclip_image_normalizer import StableUnCLIPImageNormalizer

try:
  if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_torch_and_transformers_objects import StableDiffusionImageVariationPipeline
else:
  from .pipeline_stable_diffusion_image_variation import StableDiffusionImageVariationPipeline


try:
  if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.26.0""")):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_torch_and_transformers_objects import (
      StableDiffusionDepthaImgPipeline,
      StableDiffusionDiffEditPipeline,
      StableDiffusionPixaPixZeroPipeline,
  )
else:
  from .pipeline_stable_diffusion_depthaimg import StableDiffusionDepthaImgPipeline
  from .pipeline_stable_diffusion_diffedit import StableDiffusionDiffEditPipeline
  from .pipeline_stable_diffusion_pixapix_zero import StableDiffusionPixaPixZeroPipeline


try:
  if not (
      is_torch_available()
      and is_transformers_available()
      and is_k_diffusion_available()
      and is_k_diffusion_version(""">=""", """0.0.12""")
  ):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_torch_and_transformers_and_k_diffusion_objects import *  # noqa F403
else:
  from .pipeline_stable_diffusion_k_diffusion import StableDiffusionKDiffusionPipeline

try:
  if not (is_transformers_available() and is_onnx_available()):
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  from ...utils.dummy_onnx_objects import *  # noqa F403
else:
  from .pipeline_onnx_stable_diffusion import OnnxStableDiffusionPipeline, StableDiffusionOnnxPipeline
  from .pipeline_onnx_stable_diffusion_imgaimg import OnnxStableDiffusionImgaImgPipeline
  from .pipeline_onnx_stable_diffusion_inpaint import OnnxStableDiffusionInpaintPipeline
  from .pipeline_onnx_stable_diffusion_inpaint_legacy import OnnxStableDiffusionInpaintPipelineLegacy
  from .pipeline_onnx_stable_diffusion_upscale import OnnxStableDiffusionUpscalePipeline

if is_transformers_available() and is_flax_available():
  import flax







  @flax.struct.dataclass
  class 	__lowerCAmelCase      (       _UpperCamelCase	):
     _UpperCamelCase			:    np.ndarray
     _UpperCamelCase			:    List[bool]







  from ...schedulers.scheduling_pndm_flax import PNDMSchedulerState
  from .pipeline_flax_stable_diffusion import FlaxStableDiffusionPipeline
  from .pipeline_flax_stable_diffusion_imgaimg import FlaxStableDiffusionImgaImgPipeline
  from .pipeline_flax_stable_diffusion_inpaint import FlaxStableDiffusionInpaintPipeline
  from .safety_checker_flax import FlaxStableDiffusionSafetyChecker

