






import gc
import random
import tempfile
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel
from diffusers.pipelines.semantic_stable_diffusion import SemanticStableDiffusionPipeline as StableDiffusionPipeline
from diffusers.utils import floats_tensor, nightly, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu


enable_full_determinism()
class 					a					(				unittest.TestCase     ):



      """simple docstring"""


      def 			UpperCAmelCase   (   self      :    int      )							->   Optional[int]:
        # clean up the VRAM after each test
        super().tearDown()
        gc.collect()
        torch.cuda.empty_cache()
      @property
      def 			UpperCAmelCase   (   self      :    Optional[Any]      )							->   Dict:
        __UpperCAmelCase							:			List[Any]     =						1
        __UpperCAmelCase							:			Any     =						3
        __UpperCAmelCase							:			Optional[int]     =						(32, 32)

        __UpperCAmelCase							:			Union[str, Any]     =						floats_tensor((batch_size, num_channels) + sizes	,   rng=random.Random(0      )      ).to(__lowercase      )
        return image
      @property
      def 			UpperCAmelCase   (   self      :    List[str]      )							->   List[str]:
        torch.manual_seed(0      )
        __UpperCAmelCase							:			Optional[Any]     =						UNetaDConditionModel(
            block_out_channels=(32, 64)	,   layers_per_block=2	,   sample_size=32	,   in_channels=4	,   out_channels=4	,   down_block_types=("""DownBlock2D""", """CrossAttnDownBlock2D""")	,   up_block_types=("""CrossAttnUpBlock2D""", """UpBlock2D""")	,   cross_attention_dim=32	,   )
        return model
      @property
      def 			UpperCAmelCase   (   self      :    Optional[Any]      )							->   Optional[int]:
        torch.manual_seed(0      )
        __UpperCAmelCase							:			Tuple     =						AutoencoderKL(
            block_out_channels=[32, 64]	,   in_channels=3	,   out_channels=3	,   down_block_types=["""DownEncoderBlock2D""", """DownEncoderBlock2D"""]	,   up_block_types=["""UpDecoderBlock2D""", """UpDecoderBlock2D"""]	,   latent_channels=4	,   )
        return model
      @property
      def 			UpperCAmelCase   (   self      :    List[Any]      )							->   List[Any]:
        torch.manual_seed(0      )
        __UpperCAmelCase							:			Optional[int]     =						CLIPTextConfig(
            bos_token_id=0	,   eos_token_id=2	,   hidden_size=32	,   intermediate_size=37	,   layer_norm_eps=1e-0_5	,   num_attention_heads=4	,   num_hidden_layers=5	,   pad_token_id=1	,   vocab_size=1000	,   )
        return CLIPTextModel(__lowercase      )
      @property
      def 			UpperCAmelCase   (   self      :    Optional[int]      )							->   Any:
        def extract(*__lowercase      :    Dict	,   **__lowercase      :    Any      ):
          class 					a					:



                """simple docstring"""


                def __init__(   self      :    str      )							->   Tuple:
                  __UpperCAmelCase							:			List[Any]     =						torch.ones([0]      )




                def 			UpperCAmelCase   (   self      :    int	,   __lowercase      :    List[str]      )							->   List[str]:
                  self.pixel_values.to(__lowercase      )
                  return self


          return Out()

        return extract
      def 			UpperCAmelCase   (   self      :    Union[str, Any]      )							->   List[Any]:
        __UpperCAmelCase							:			Tuple     =						"""cpu"""  # ensure determinism for the device-dependent torch.Generator
        __UpperCAmelCase							:			Tuple     =						self.dummy_cond_unet
        __UpperCAmelCase							:			int     =						DDIMScheduler(
            beta_start=0.00_085	,   beta_end=0.012	,   beta_schedule="""scaled_linear"""	,   clip_sample=__lowercase	,   set_alpha_to_one=__lowercase	,   )

        __UpperCAmelCase							:			Tuple     =						self.dummy_vae
        __UpperCAmelCase							:			Any     =						self.dummy_text_encoder
        __UpperCAmelCase							:			Optional[int]     =						CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""      )

        # make sure here that pndm scheduler skips prk
        __UpperCAmelCase							:			List[Any]     =						StableDiffusionPipeline(
            unet=__lowercase	,   scheduler=__lowercase	,   vae=__lowercase	,   text_encoder=__lowercase	,   tokenizer=__lowercase	,   safety_checker=__lowercase	,   feature_extractor=self.dummy_extractor	,   )
        __UpperCAmelCase							:			List[Any]     =						sd_pipe.to(__lowercase      )
        sd_pipe.set_progress_bar_config(disable=__lowercase      )

        __UpperCAmelCase							:			int     =						"""A painting of a squirrel eating a burger"""

        __UpperCAmelCase							:			List[str]     =						torch.Generator(device=__lowercase      ).manual_seed(0      )
        __UpperCAmelCase							:			List[Any]     =						sd_pipe([prompt]	,   generator=__lowercase	,   guidance_scale=6.0	,   num_inference_steps=2	,   output_type="""np"""      )
        __UpperCAmelCase							:			List[str]     =						output.images

        __UpperCAmelCase							:			Optional[Any]     =						torch.Generator(device=__lowercase      ).manual_seed(0      )
        __UpperCAmelCase							:			Tuple     =						sd_pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=6.0	,   num_inference_steps=2	,   output_type="""np"""	,   return_dict=__lowercase	,   )[0]

        __UpperCAmelCase							:			List[str]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Tuple     =						image_from_tuple[0, -3:, -3:, -1]

        assert image.shape == (1, 64, 64, 3)
        __UpperCAmelCase							:			List[Any]     =						np.array([0.5_753, 0.6_114, 0.5_001, 0.5_034, 0.5_470, 0.4_729, 0.4_971, 0.4_867, 0.4_867]      )

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2
        assert np.abs(image_from_tuple_slice.flatten() - expected_slice      ).max() < 1e-2
      def 			UpperCAmelCase   (   self      :    Tuple      )							->   Optional[Any]:
        __UpperCAmelCase							:			int     =						"""cpu"""  # ensure determinism for the device-dependent torch.Generator
        __UpperCAmelCase							:			Optional[Any]     =						self.dummy_cond_unet
        __UpperCAmelCase							:			Any     =						PNDMScheduler(skip_prk_steps=__lowercase      )
        __UpperCAmelCase							:			str     =						self.dummy_vae
        __UpperCAmelCase							:			Any     =						self.dummy_text_encoder
        __UpperCAmelCase							:			str     =						CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""      )

        # make sure here that pndm scheduler skips prk
        __UpperCAmelCase							:			Any     =						StableDiffusionPipeline(
            unet=__lowercase	,   scheduler=__lowercase	,   vae=__lowercase	,   text_encoder=__lowercase	,   tokenizer=__lowercase	,   safety_checker=__lowercase	,   feature_extractor=self.dummy_extractor	,   )
        __UpperCAmelCase							:			List[Any]     =						sd_pipe.to(__lowercase      )
        sd_pipe.set_progress_bar_config(disable=__lowercase      )

        __UpperCAmelCase							:			int     =						"""A painting of a squirrel eating a burger"""
        __UpperCAmelCase							:			int     =						torch.Generator(device=__lowercase      ).manual_seed(0      )
        __UpperCAmelCase							:			Any     =						sd_pipe([prompt]	,   generator=__lowercase	,   guidance_scale=6.0	,   num_inference_steps=2	,   output_type="""np"""      )

        __UpperCAmelCase							:			List[Any]     =						output.images

        __UpperCAmelCase							:			Dict     =						torch.Generator(device=__lowercase      ).manual_seed(0      )
        __UpperCAmelCase							:			List[str]     =						sd_pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=6.0	,   num_inference_steps=2	,   output_type="""np"""	,   return_dict=__lowercase	,   )[0]

        __UpperCAmelCase							:			List[str]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Any     =						image_from_tuple[0, -3:, -3:, -1]

        assert image.shape == (1, 64, 64, 3)
        __UpperCAmelCase							:			str     =						np.array([0.5_122, 0.5_712, 0.4_825, 0.5_053, 0.5_646, 0.4_769, 0.5_179, 0.4_894, 0.4_994]      )

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2
        assert np.abs(image_from_tuple_slice.flatten() - expected_slice      ).max() < 1e-2
      def 			UpperCAmelCase   (   self      :    Union[str, Any]      )							->   Dict:
        __UpperCAmelCase							:			Dict     =						StableDiffusionPipeline.from_pretrained(
            """hf-internal-testing/tiny-stable-diffusion-lms-pipe"""	,   safety_checker=__lowercase      )
        assert isinstance(__lowercase	,   __lowercase      )
        assert isinstance(pipe.scheduler	,   __lowercase      )
        assert pipe.safety_checker is None

        __UpperCAmelCase							:			Tuple     =						pipe("""example prompt"""	,   num_inference_steps=2      ).images[0]
        assert image is not None

        # check that there's no error when saving a pipeline with one of the models being None
        with tempfile.TemporaryDirectory() as tmpdirname:
          pipe.save_pretrained(__lowercase      )
          __UpperCAmelCase							:			Optional[int]     =						StableDiffusionPipeline.from_pretrained(__lowercase      )

        # sanity check that the pipeline still works
        assert pipe.safety_checker is None
        __UpperCAmelCase							:			Union[str, Any]     =						pipe("""example prompt"""	,   num_inference_steps=2      ).images[0]
        assert image is not None




      @unittest.skipIf(torch_device != """cuda"""	,   """This test requires a GPU"""      )
      def 			UpperCAmelCase   (   self      :    int      )							->   Optional[int]:
        __UpperCAmelCase							:			Union[str, Any]     =						self.dummy_cond_unet
        __UpperCAmelCase							:			Union[str, Any]     =						PNDMScheduler(skip_prk_steps=__lowercase      )
        __UpperCAmelCase							:			List[Any]     =						self.dummy_vae
        __UpperCAmelCase							:			Union[str, Any]     =						self.dummy_text_encoder
        __UpperCAmelCase							:			Tuple     =						CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip"""      )

        # put models in fp16
        __UpperCAmelCase							:			Tuple     =						unet.half()
        __UpperCAmelCase							:			Optional[Any]     =						vae.half()
        __UpperCAmelCase							:			Any     =						bert.half()

        # make sure here that pndm scheduler skips prk
        __UpperCAmelCase							:			str     =						StableDiffusionPipeline(
            unet=__lowercase	,   scheduler=__lowercase	,   vae=__lowercase	,   text_encoder=__lowercase	,   tokenizer=__lowercase	,   safety_checker=__lowercase	,   feature_extractor=self.dummy_extractor	,   )
        __UpperCAmelCase							:			Dict     =						sd_pipe.to(__lowercase      )
        sd_pipe.set_progress_bar_config(disable=__lowercase      )

        __UpperCAmelCase							:			Dict     =						"""A painting of a squirrel eating a burger"""
        __UpperCAmelCase							:			str     =						sd_pipe([prompt]	,   num_inference_steps=2	,   output_type="""np"""      ).images

        assert image.shape == (1, 64, 64, 3)


@nightly
@require_torch_gpu
class 					a					(				unittest.TestCase     ):



      """simple docstring"""


      def 			UpperCAmelCase   (   self      :    int      )							->   Tuple:
        # clean up the VRAM after each test
        super().tearDown()
        gc.collect()
        torch.cuda.empty_cache()
      def 			UpperCAmelCase   (   self      :    Any      )							->   str:
        __UpperCAmelCase							:			Tuple     =						"""cuda"""
        __UpperCAmelCase							:			Dict     =						StableDiffusionPipeline.from_pretrained("""runwayml/stable-diffusion-v1-5"""      )
        __UpperCAmelCase							:			List[Any]     =						pipe.to(__lowercase      )
        pipe.set_progress_bar_config(disable=__lowercase      )

        __UpperCAmelCase							:			Tuple     =						"""a photo of a cat"""
        __UpperCAmelCase							:			Optional[Any]     =						{
            """editing_prompt""": ["""sunglasses"""],
            """reverse_editing_direction""": [False],
            """edit_warmup_steps""": 10,
            """edit_guidance_scale""": 6,
            """edit_threshold""": 0.95,
            """edit_momentum_scale""": 0.5,
            """edit_mom_beta""": 0.6,
        }

        __UpperCAmelCase							:			Optional[int]     =						3
        __UpperCAmelCase							:			List[str]     =						7

        # no sega enabled
        __UpperCAmelCase							:			List[Any]     =						torch.Generator(__lowercase      )
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			Any     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   )

        __UpperCAmelCase							:			List[str]     =						output.images
        __UpperCAmelCase							:			Tuple     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Union[str, Any]     =						[
            0.34_673_113,
            0.38_492_733,
            0.37_597_352,
            0.34_086_335,
            0.35_650_748,
            0.35_579_205,
            0.3_384_763,
            0.34_340_236,
            0.3_573_271,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2

        # with sega enabled
        # generator = torch.manual_seed(seed)
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			List[str]     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   **__lowercase	,   )

        __UpperCAmelCase							:			int     =						output.images
        __UpperCAmelCase							:			List[str]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Tuple     =						[
            0.41_887_826,
            0.37_728_766,
            0.30_138_272,
            0.41_416_335,
            0.41_664_985,
            0.36_283_392,
            0.36_191_246,
            0.43_364_465,
            0.43_001_732,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2
      def 			UpperCAmelCase   (   self      :    str      )							->   Tuple:
        __UpperCAmelCase							:			List[str]     =						"""cuda"""
        __UpperCAmelCase							:			List[Any]     =						StableDiffusionPipeline.from_pretrained("""runwayml/stable-diffusion-v1-5"""      )
        __UpperCAmelCase							:			List[Any]     =						pipe.to(__lowercase      )
        pipe.set_progress_bar_config(disable=__lowercase      )

        __UpperCAmelCase							:			str     =						"""an image of a crowded boulevard, realistic, 4k"""
        __UpperCAmelCase							:			int     =						{
            """editing_prompt""": """crowd, crowded, people""",
            """reverse_editing_direction""": True,
            """edit_warmup_steps""": 10,
            """edit_guidance_scale""": 8.3,
            """edit_threshold""": 0.9,
            """edit_momentum_scale""": 0.5,
            """edit_mom_beta""": 0.6,
        }

        __UpperCAmelCase							:			Optional[Any]     =						9
        __UpperCAmelCase							:			Union[str, Any]     =						7

        # no sega enabled
        __UpperCAmelCase							:			Union[str, Any]     =						torch.Generator(__lowercase      )
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			str     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   )

        __UpperCAmelCase							:			Tuple     =						output.images
        __UpperCAmelCase							:			Tuple     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Dict     =						[
            0.43_497_998,
            0.91_814_065,
            0.7_540_739,
            0.55_580_205,
            0.8_467_265,
            0.5_389_691,
            0.62_574_506,
            0.58_897_763,
            0.50_926_757,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2

        # with sega enabled
        # generator = torch.manual_seed(seed)
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			Any     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   **__lowercase	,   )

        __UpperCAmelCase							:			Optional[int]     =						output.images
        __UpperCAmelCase							:			List[Any]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			List[Any]     =						[
            0.3_089_719,
            0.30_500_144,
            0.29_016_042,
            0.30_630_964,
            0.325_687,
            0.29_419_225,
            0.2_908_091,
            0.28_723_598,
            0.27_696_294,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2
      def 			UpperCAmelCase   (   self      :    Dict      )							->   Dict:
        __UpperCAmelCase							:			Tuple     =						"""cuda"""
        __UpperCAmelCase							:			List[Any]     =						StableDiffusionPipeline.from_pretrained("""runwayml/stable-diffusion-v1-5"""      )
        __UpperCAmelCase							:			Dict     =						pipe.to(__lowercase      )
        pipe.set_progress_bar_config(disable=__lowercase      )

        __UpperCAmelCase							:			Any     =						"""a castle next to a river"""
        __UpperCAmelCase							:			List[Any]     =						{
            """editing_prompt""": ["""boat on a river, boat""", """monet, impression, sunrise"""],
            """reverse_editing_direction""": False,
            """edit_warmup_steps""": [15, 18],
            """edit_guidance_scale""": 6,
            """edit_threshold""": [0.9, 0.8],
            """edit_momentum_scale""": 0.5,
            """edit_mom_beta""": 0.6,
        }

        __UpperCAmelCase							:			List[str]     =						48
        __UpperCAmelCase							:			str     =						7

        # no sega enabled
        __UpperCAmelCase							:			List[Any]     =						torch.Generator(__lowercase      )
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			Tuple     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   )

        __UpperCAmelCase							:			int     =						output.images
        __UpperCAmelCase							:			Optional[Any]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Any     =						[
            0.75_163_555,
            0.76_037_145,
            0.61_785,
            0.9_189_673,
            0.8_627_701,
            0.85_189_694,
            0.8_512_813,
            0.87_012_076,
            0.8_312_857,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2

        # with sega enabled
        # generator = torch.manual_seed(seed)
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			List[str]     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   **__lowercase	,   )

        __UpperCAmelCase							:			str     =						output.images
        __UpperCAmelCase							:			Optional[int]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Union[str, Any]     =						[
            0.73_553_365,
            0.7_537_271,
            0.74_341_905,
            0.66_480_356,
            0.6_472_925,
            0.63_039_416,
            0.64_812_905,
            0.6_749_717,
            0.6_517_102,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2




      def 			UpperCAmelCase   (   self      :    List[str]      )							->   List[Any]:
        __UpperCAmelCase							:			str     =						"""cuda"""
        __UpperCAmelCase							:			Dict     =						StableDiffusionPipeline.from_pretrained("""runwayml/stable-diffusion-v1-5"""	,   torch_dtype=torch.floataa      )
        __UpperCAmelCase							:			List[Any]     =						pipe.to(__lowercase      )
        pipe.set_progress_bar_config(disable=__lowercase      )

        __UpperCAmelCase							:			Union[str, Any]     =						"""a photo of a cat"""
        __UpperCAmelCase							:			List[Any]     =						{
            """editing_prompt""": ["""sunglasses"""],
            """reverse_editing_direction""": [False],
            """edit_warmup_steps""": 10,
            """edit_guidance_scale""": 6,
            """edit_threshold""": 0.95,
            """edit_momentum_scale""": 0.5,
            """edit_mom_beta""": 0.6,
        }

        __UpperCAmelCase							:			Optional[Any]     =						3
        __UpperCAmelCase							:			Tuple     =						7

        # no sega enabled
        __UpperCAmelCase							:			Tuple     =						torch.Generator(__lowercase      )
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			int     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   )

        __UpperCAmelCase							:			int     =						output.images
        __UpperCAmelCase							:			Union[str, Any]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Dict     =						[
            0.34_887_695,
            0.3_876_953,
            0.375,
            0.34_423_828,
            0.3_581_543,
            0.35_717_773,
            0.3_383_789,
            0.34_570_312,
            0.359_375,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2

        # with sega enabled
        # generator = torch.manual_seed(seed)
        generator.manual_seed(__lowercase      )
        __UpperCAmelCase							:			Dict     =						pipe(
            [prompt]	,   generator=__lowercase	,   guidance_scale=__lowercase	,   num_inference_steps=50	,   output_type="""np"""	,   width=512	,   height=512	,   **__lowercase	,   )

        __UpperCAmelCase							:			int     =						output.images
        __UpperCAmelCase							:			Optional[int]     =						image[0, -3:, -3:, -1]
        __UpperCAmelCase							:			Dict     =						[
            0.42_285_156,
            0.36_914_062,
            0.29_077_148,
            0.42_041_016,
            0.41_918_945,
            0.35_498_047,
            0.3_618_164,
            0.4_423_828,
            0.43_115_234,
        ]

        assert image.shape == (1, 512, 512, 3)

        assert np.abs(image_slice.flatten() - expected_slice      ).max() < 1e-2










from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


a	: Optional[int]      =				{
    "configuration_deformable_detr": ["DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeformableDetrConfig"],
}

try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a	: Optional[int]      =				["DeformableDetrFeatureExtractor"]
       a	: List[str]      =				["DeformableDetrImageProcessor"]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a	: List[Any]      =				[
           "DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST",
           "DeformableDetrForObjectDetection",
           "DeformableDetrModel",
           "DeformableDetrPreTrainedModel",
       ]


if TYPE_CHECKING:
       from .configuration_deformable_detr import DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP, DeformableDetrConfig

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .feature_extraction_deformable_detr import DeformableDetrFeatureExtractor
              from .image_processing_deformable_detr import DeformableDetrImageProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_deformable_detr import (
                  DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST,
                  DeformableDetrForObjectDetection,
                  DeformableDetrModel,
                  DeformableDetrPreTrainedModel,
              )

else:
       import sys

       a	: List[Any]      =				_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


