


import tempfile
import unittest

import numpy as np

from diffusers import (
    DDIMScheduler,
    DPMSolverMultistepScheduler,
    EulerAncestralDiscreteScheduler,
    EulerDiscreteScheduler,
    LMSDiscreteScheduler,
    OnnxStableDiffusionPipeline,
    PNDMScheduler,
)
from diffusers.utils.testing_utils import is_onnx_available, nightly, require_onnxruntime, require_torch_gpu

from ..test_pipelines_onnx_common import OnnxPipelineTesterMixin


if is_onnx_available():
 import onnxruntime as ort






class _lowerCamelCase(						_a, unittest.TestCase   ):
       lowercase_ :	Union[str, Any]     =			"""hf-internal-testing/tiny-random-OnnxStableDiffusionPipeline"""
       def 			UpperCamelCase     (					self,      lowerCamelCase=0)       ->   Optional[int]:




           """simple docstring"""

           _lowercase       :							str      		=		np.random.RandomState(lowerCamelCase)
           _lowercase       :							List[Any]      		=		{
               'prompt': 'A painting of a squirrel eating a burger',
               'generator': generator,
               'num_inference_steps': 2,
               'guidance_scale': 7.5,
               'output_type': 'numpy',
           }
           return inputs
       def 			UpperCamelCase     (					self)       ->   List[Any]:




           """simple docstring"""

           _lowercase       :							int      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							Tuple      		=		self.get_dummy_inputs()
           _lowercase       :							Optional[Any]      		=		pipe(**lowerCamelCase).images
           _lowercase       :							Any      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 1_28, 1_28, 3)
           _lowercase       :							Tuple      		=		np.array([0.6_5_0_7_2, 0.5_8_4_9_2, 0.4_8_2_1_9, 0.5_5_5_2_1, 0.5_3_1_8_0, 0.5_5_9_3_9, 0.5_0_6_9_7, 0.3_9_8_0_0, 0.4_6_4_5_5])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2
       def 			UpperCamelCase     (					self)       ->   str:




           """simple docstring"""

           _lowercase       :							List[Any]      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           _lowercase       :							List[Any]      		=		PNDMScheduler.from_config(pipe.scheduler.config,      skip_prk_steps=lowerCamelCase)
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							Dict      		=		self.get_dummy_inputs()
           _lowercase       :							str      		=		pipe(**lowerCamelCase).images
           _lowercase       :							Union[str, Any]      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 1_28, 1_28, 3)
           _lowercase       :							List[str]      		=		np.array([0.6_5_8_6_3, 0.5_9_4_2_5, 0.4_9_3_2_6, 0.5_6_3_1_3, 0.5_3_8_7_5, 0.5_6_6_2_7, 0.5_1_0_6_5, 0.3_9_7_7_7, 0.4_6_3_3_0])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2
       def 			UpperCamelCase     (					self)       ->   int:




           """simple docstring"""

           _lowercase       :							List[Any]      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           _lowercase       :							List[str]      		=		LMSDiscreteScheduler.from_config(pipe.scheduler.config)
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							List[Any]      		=		self.get_dummy_inputs()
           _lowercase       :							Union[str, Any]      		=		pipe(**lowerCamelCase).images
           _lowercase       :							Tuple      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 1_28, 1_28, 3)
           _lowercase       :							str      		=		np.array([0.5_3_7_5_5, 0.6_0_7_8_6, 0.4_7_4_0_2, 0.4_9_4_8_8, 0.5_1_8_6_9, 0.4_9_8_1_9, 0.4_7_9_8_5, 0.3_8_9_5_7, 0.4_4_2_7_9])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2
       def 			UpperCamelCase     (					self)       ->   List[str]:




           """simple docstring"""

           _lowercase       :							Union[str, Any]      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           _lowercase       :							Optional[int]      		=		EulerDiscreteScheduler.from_config(pipe.scheduler.config)
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							List[Any]      		=		self.get_dummy_inputs()
           _lowercase       :							int      		=		pipe(**lowerCamelCase).images
           _lowercase       :							Any      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 1_28, 1_28, 3)
           _lowercase       :							Any      		=		np.array([0.5_3_7_5_5, 0.6_0_7_8_6, 0.4_7_4_0_2, 0.4_9_4_8_8, 0.5_1_8_6_9, 0.4_9_8_1_9, 0.4_7_9_8_5, 0.3_8_9_5_7, 0.4_4_2_7_9])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2
       def 			UpperCamelCase     (					self)       ->   Any:




           """simple docstring"""

           _lowercase       :							Dict      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           _lowercase       :							Union[str, Any]      		=		EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							List[Any]      		=		self.get_dummy_inputs()
           _lowercase       :							List[str]      		=		pipe(**lowerCamelCase).images
           _lowercase       :							Any      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 1_28, 1_28, 3)
           _lowercase       :							Any      		=		np.array([0.5_3_8_1_7, 0.6_0_8_1_2, 0.4_7_3_8_4, 0.4_9_5_3_0, 0.5_1_8_9_4, 0.4_9_8_1_4, 0.4_7_9_8_4, 0.3_8_9_5_8, 0.4_4_2_7_1])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2
       def 			UpperCamelCase     (					self)       ->   int:




           """simple docstring"""

           _lowercase       :							int      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           _lowercase       :							int      		=		DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							List[Any]      		=		self.get_dummy_inputs()
           _lowercase       :							Optional[Any]      		=		pipe(**lowerCamelCase).images
           _lowercase       :							List[Any]      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 1_28, 1_28, 3)
           _lowercase       :							int      		=		np.array([0.5_3_8_9_5, 0.6_0_8_0_8, 0.4_7_9_3_3, 0.4_9_6_0_8, 0.5_1_8_8_6, 0.4_9_9_5_0, 0.4_8_0_5_3, 0.3_8_9_5_7, 0.4_4_2_0_0])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-2
       def 			UpperCamelCase     (					self)       ->   Dict:




           """simple docstring"""

           _lowercase       :							List[Any]      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							int      		=		self.get_dummy_inputs()
           _lowercase       :							str      		=		3 * [inputs['prompt']]

           # forward
           _lowercase       :							Optional[Any]      		=		pipe(**lowerCamelCase)
           _lowercase       :							Optional[Any]      		=		output.images[0, -3:, -3:, -1]

           _lowercase       :							List[Any]      		=		self.get_dummy_inputs()
           _lowercase       :							Any      		=		3 * [inputs.pop('prompt')]

           _lowercase       :							Optional[int]      		=		pipe.tokenizer(
               lowerCamelCase,      padding='max_length',      max_length=pipe.tokenizer.model_max_length,      truncation=lowerCamelCase,      return_tensors='np',      )
           _lowercase       :							Optional[int]      		=		text_inputs['input_ids']

           _lowercase       :							str      		=		pipe.text_encoder(input_ids=text_inputs.astype(np.intaa))[0]

           _lowercase       :							Tuple      		=		prompt_embeds

           # forward
           _lowercase       :							Union[str, Any]      		=		pipe(**lowerCamelCase)
           _lowercase       :							Tuple      		=		output.images[0, -3:, -3:, -1]

           assert np.abs(image_slice_a.flatten() - image_slice_a.flatten()).max() < 1E-4




       def 			UpperCamelCase     (					self)       ->   Dict:




           """simple docstring"""

           _lowercase       :							List[str]      		=		OnnxStableDiffusionPipeline.from_pretrained(self.hub_checkpoint,      provider='CPUExecutionProvider')
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							Union[str, Any]      		=		self.get_dummy_inputs()
           _lowercase       :							Any      		=		3 * ['this is a negative prompt']
           _lowercase       :							int      		=		negative_prompt
           _lowercase       :							List[str]      		=		3 * [inputs['prompt']]

           # forward
           _lowercase       :							str      		=		pipe(**lowerCamelCase)
           _lowercase       :							Tuple      		=		output.images[0, -3:, -3:, -1]

           _lowercase       :							Optional[Any]      		=		self.get_dummy_inputs()
           _lowercase       :							int      		=		3 * [inputs.pop('prompt')]

           _lowercase       :							Optional[int]      		=		[]
           for p in [prompt, negative_prompt]:
               _lowercase       :							int      		=		pipe.tokenizer(
                   lowerCamelCase,      padding='max_length',      max_length=pipe.tokenizer.model_max_length,      truncation=lowerCamelCase,      return_tensors='np',      )
               _lowercase       :							List[Any]      		=		text_inputs['input_ids']

               embeds.append(pipe.text_encoder(input_ids=text_inputs.astype(np.intaa))[0])

           _lowercase		,				_lowercase       :							Optional[Any]      		=		embeds

           # forward
           _lowercase       :							List[str]      		=		pipe(**lowerCamelCase)
           _lowercase       :							str      		=		output.images[0, -3:, -3:, -1]

           assert np.abs(image_slice_a.flatten() - image_slice_a.flatten()).max() < 1E-4






@nightly
@require_onnxruntime
@require_torch_gpu
class _lowerCamelCase(						unittest.TestCase   ):
       @property
       def 			UpperCamelCase     (					self)       ->   Any:




           """simple docstring"""

           return (
               "CUDAExecutionProvider",
               {
                   "gpu_mem_limit": "15000000000",  # 15GB
                   "arena_extend_strategy": "kSameAsRequested",
               },
           )
       @property
       def 			UpperCamelCase     (					self)       ->   Any:




           """simple docstring"""

           _lowercase       :							Union[str, Any]      		=		ort.SessionOptions()
           _lowercase       :							str      		=		False
           return options
       def 			UpperCamelCase     (					self)       ->   Dict:




           """simple docstring"""

           _lowercase       :							Dict      		=		OnnxStableDiffusionPipeline.from_pretrained(
               'CompVis/stable-diffusion-v1-4',      revision='onnx',      safety_checker=lowerCamelCase,      feature_extractor=lowerCamelCase,      provider=self.gpu_provider,      sess_options=self.gpu_options,      )
           sd_pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							Tuple      		=		'A painting of a squirrel eating a burger'
           np.random.seed(0)
           _lowercase       :							int      		=		sd_pipe([prompt],      guidance_scale=6.0,      num_inference_steps=10,      output_type='np')
           _lowercase       :							Union[str, Any]      		=		output.images

           _lowercase       :							Optional[int]      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 5_12, 5_12, 3)
           _lowercase       :							Optional[int]      		=		np.array([0.0_4_5_2, 0.0_3_9_0, 0.0_0_8_7, 0.0_3_5_0, 0.0_6_1_7, 0.0_3_6_4, 0.0_5_4_4, 0.0_5_2_3, 0.0_7_2_0])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-3
       def 			UpperCamelCase     (					self)       ->   Optional[Any]:




           """simple docstring"""

           _lowercase       :							Union[str, Any]      		=		DDIMScheduler.from_pretrained(
               'runwayml/stable-diffusion-v1-5',      subfolder='scheduler',      revision='onnx')
           _lowercase       :							int      		=		OnnxStableDiffusionPipeline.from_pretrained(
               'runwayml/stable-diffusion-v1-5',      revision='onnx',      scheduler=lowerCamelCase,      safety_checker=lowerCamelCase,      feature_extractor=lowerCamelCase,      provider=self.gpu_provider,      sess_options=self.gpu_options,      )
           sd_pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							Dict      		=		'open neural network exchange'
           _lowercase       :							Union[str, Any]      		=		np.random.RandomState(0)
           _lowercase       :							int      		=		sd_pipe([prompt],      guidance_scale=7.5,      num_inference_steps=10,      generator=lowerCamelCase,      output_type='np')
           _lowercase       :							Tuple      		=		output.images
           _lowercase       :							Union[str, Any]      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 5_12, 5_12, 3)
           _lowercase       :							List[Any]      		=		np.array([0.2_8_6_7, 0.1_9_7_4, 0.1_4_8_1, 0.7_2_9_4, 0.7_2_5_1, 0.6_6_6_7, 0.4_1_9_4, 0.5_6_4_2, 0.6_4_8_6])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-3
       def 			UpperCamelCase     (					self)       ->   Tuple:




           """simple docstring"""

           _lowercase       :							int      		=		LMSDiscreteScheduler.from_pretrained(
               'runwayml/stable-diffusion-v1-5',      subfolder='scheduler',      revision='onnx')
           _lowercase       :							Optional[int]      		=		OnnxStableDiffusionPipeline.from_pretrained(
               'runwayml/stable-diffusion-v1-5',      revision='onnx',      scheduler=lowerCamelCase,      safety_checker=lowerCamelCase,      feature_extractor=lowerCamelCase,      provider=self.gpu_provider,      sess_options=self.gpu_options,      )
           sd_pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							int      		=		'open neural network exchange'
           _lowercase       :							Optional[Any]      		=		np.random.RandomState(0)
           _lowercase       :							List[str]      		=		sd_pipe([prompt],      guidance_scale=7.5,      num_inference_steps=10,      generator=lowerCamelCase,      output_type='np')
           _lowercase       :							Dict      		=		output.images
           _lowercase       :							List[str]      		=		image[0, -3:, -3:, -1]

           assert image.shape == (1, 5_12, 5_12, 3)
           _lowercase       :							str      		=		np.array([0.2_3_0_6, 0.1_9_5_9, 0.1_5_9_3, 0.6_5_4_9, 0.6_3_9_4, 0.5_4_0_8, 0.5_0_6_5, 0.6_0_1_0, 0.6_1_6_1])

           assert np.abs(image_slice.flatten() - expected_slice).max() < 1E-3
       def 			UpperCamelCase     (					self)       ->   List[Any]:




           """simple docstring"""

           _lowercase       :							Dict      		=		0

           def test_callback_fn(lowerCamelCase,      lowerCamelCase,      lowerCamelCase) -> None:
               _lowercase       :							int      		=		True
               nonlocal number_of_steps
               number_of_steps += 1
               if step == 0:
                   assert latents.shape == (1, 4, 64, 64)
                   _lowercase       :							Tuple      		=		latents[0, -3:, -3:, -1]
                   _lowercase       :							List[str]      		=		np.array(
                       [-0.6_7_7_2, -0.3_8_3_5, -1.2_4_5_6, 0.1_9_0_5, -1.0_9_7_4, 0.6_9_6_7, -1.9_3_5_3, 0.0_1_7_8, 1.0_1_6_7])

                   assert np.abs(latents_slice.flatten() - expected_slice).max() < 1E-3
               elif step == 5:
                   assert latents.shape == (1, 4, 64, 64)
                   _lowercase       :							int      		=		latents[0, -3:, -3:, -1]
                   _lowercase       :							Optional[int]      		=		np.array(
                       [-0.3_3_5_1, 0.2_2_4_1, -0.1_8_3_7, -0.2_3_2_5, -0.6_5_7_7, 0.3_3_9_3, -0.0_2_4_1, 0.5_8_9_9, 1.3_8_7_5])

                   assert np.abs(latents_slice.flatten() - expected_slice).max() < 1E-3

           _lowercase       :							Any      		=		False

           _lowercase       :							List[str]      		=		OnnxStableDiffusionPipeline.from_pretrained(
               'runwayml/stable-diffusion-v1-5',      revision='onnx',      safety_checker=lowerCamelCase,      feature_extractor=lowerCamelCase,      provider=self.gpu_provider,      sess_options=self.gpu_options,      )
           pipe.set_progress_bar_config(disable=lowerCamelCase)

           _lowercase       :							str      		=		'Andromeda galaxy in a bottle'

           _lowercase       :							Union[str, Any]      		=		np.random.RandomState(0)
           pipe(
               prompt=lowerCamelCase,      num_inference_steps=5,      guidance_scale=7.5,      generator=lowerCamelCase,      callback=lowerCamelCase,      callback_steps=1,      )
           assert test_callback_fn.has_been_called
           assert number_of_steps == 6




       def 			UpperCamelCase     (					self)       ->   Dict:




           """simple docstring"""

           _lowercase       :							str      		=		OnnxStableDiffusionPipeline.from_pretrained(
               'runwayml/stable-diffusion-v1-5',      revision='onnx',      safety_checker=lowerCamelCase,      feature_extractor=lowerCamelCase,      provider=self.gpu_provider,      sess_options=self.gpu_options,      )
           assert isinstance(lowerCamelCase,      lowerCamelCase)
           assert pipe.safety_checker is None

           _lowercase       :							Union[str, Any]      		=		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(lowerCamelCase)
               _lowercase       :							int      		=		OnnxStableDiffusionPipeline.from_pretrained(lowerCamelCase)

           # sanity check that the pipeline still works
           assert pipe.safety_checker is None
           _lowercase       :							Optional[int]      		=		pipe('example prompt',      num_inference_steps=2).images[0]
           assert image is not None






import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


SCREAMING_SNAKE_CASE       :      int												= logging.get_logger(__name__)

SCREAMING_SNAKE_CASE       :      List[str]												= {
    "SenseTime/deformable-detr": "https://huggingface.co/sensetime/deformable-detr/resolve/main/config.json",
    # See all Deformable DETR models at https://huggingface.co/models?filter=deformable-detr
}






class _lowerCamelCase(						_a   ):
       lowercase_ :	Dict     =			"""deformable_detr"""
       lowercase_ :	int     =			{
           """hidden_size""": """d_model""",
           """num_attention_heads""": """encoder_attention_heads""",
       }
       def __init__(					self,      lowerCamelCase=True,      lowerCamelCase=None,      lowerCamelCase=3,      lowerCamelCase=3_00,      lowerCamelCase=10_24,      lowerCamelCase=6,      lowerCamelCase=10_24,      lowerCamelCase=8,      lowerCamelCase=6,      lowerCamelCase=10_24,      lowerCamelCase=8,      lowerCamelCase=0.0,      lowerCamelCase=True,      lowerCamelCase="relu",      lowerCamelCase=2_56,      lowerCamelCase=0.1,      lowerCamelCase=0.0,      lowerCamelCase=0.0,      lowerCamelCase=0.0_2,      lowerCamelCase=1.0,      lowerCamelCase=True,      lowerCamelCase=False,      lowerCamelCase="sine",      lowerCamelCase="resnet50",      lowerCamelCase=True,      lowerCamelCase=False,      lowerCamelCase=4,      lowerCamelCase=4,      lowerCamelCase=4,      lowerCamelCase=False,      lowerCamelCase=3_00,      lowerCamelCase=False,      lowerCamelCase=1,      lowerCamelCase=5,      lowerCamelCase=2,      lowerCamelCase=1,      lowerCamelCase=1,      lowerCamelCase=5,      lowerCamelCase=2,      lowerCamelCase=0.1,      lowerCamelCase=0.2_5,      lowerCamelCase=False,      **lowerCamelCase,      )       ->   Optional[int]:




           """simple docstring"""

           if backbone_config is not None and use_timm_backbone:
               raise ValueError('You can\'t specify both `backbone_config` and `use_timm_backbone`.')

           if not use_timm_backbone:
               if backbone_config is None:
                   logger.info('`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.')
                   _lowercase       :							List[str]      		=		CONFIG_MAPPING['resnet'](out_features=['stage4'])
               elif isinstance(lowerCamelCase,      lowerCamelCase):
                   _lowercase       :							List[str]      		=		backbone_config.get('model_type')
                   _lowercase       :							str      		=		CONFIG_MAPPING[backbone_model_type]
                   _lowercase       :							Optional[int]      		=		config_class.from_dict(lowerCamelCase)
           _lowercase       :							Tuple      		=		use_timm_backbone
           _lowercase       :							List[str]      		=		backbone_config
           _lowercase       :							Tuple      		=		num_channels
           _lowercase       :							Optional[Any]      		=		num_queries
           _lowercase       :							Optional[Any]      		=		max_position_embeddings
           _lowercase       :							Optional[int]      		=		d_model
           _lowercase       :							int      		=		encoder_ffn_dim
           _lowercase       :							List[Any]      		=		encoder_layers
           _lowercase       :							str      		=		encoder_attention_heads
           _lowercase       :							str      		=		decoder_ffn_dim
           _lowercase       :							Optional[Any]      		=		decoder_layers
           _lowercase       :							List[str]      		=		decoder_attention_heads
           _lowercase       :							Optional[int]      		=		dropout
           _lowercase       :							Optional[Any]      		=		attention_dropout
           _lowercase       :							int      		=		activation_dropout
           _lowercase       :							Any      		=		activation_function
           _lowercase       :							Optional[int]      		=		init_std
           _lowercase       :							int      		=		init_xavier_std
           _lowercase       :							Union[str, Any]      		=		encoder_layerdrop
           _lowercase       :							Tuple      		=		auxiliary_loss
           _lowercase       :							Union[str, Any]      		=		position_embedding_type
           _lowercase       :							str      		=		backbone
           _lowercase       :							List[Any]      		=		use_pretrained_backbone
           _lowercase       :							Any      		=		dilation
           # deformable attributes
           _lowercase       :							Any      		=		num_feature_levels
           _lowercase       :							Dict      		=		encoder_n_points
           _lowercase       :							Dict      		=		decoder_n_points
           _lowercase       :							Dict      		=		two_stage
           _lowercase       :							Union[str, Any]      		=		two_stage_num_proposals
           _lowercase       :							str      		=		with_box_refine
           if two_stage is True and with_box_refine is False:
               raise ValueError('If two_stage is True, with_box_refine must be True.')
           # Hungarian matcher
           _lowercase       :							Tuple      		=		class_cost
           _lowercase       :							int      		=		bbox_cost
           _lowercase       :							Optional[int]      		=		giou_cost
           # Loss coefficients
           _lowercase       :							Optional[Any]      		=		mask_loss_coefficient
           _lowercase       :							Dict      		=		dice_loss_coefficient
           _lowercase       :							Tuple      		=		bbox_loss_coefficient
           _lowercase       :							Optional[int]      		=		giou_loss_coefficient
           _lowercase       :							Union[str, Any]      		=		eos_coefficient
           _lowercase       :							Union[str, Any]      		=		focal_alpha
           _lowercase       :							Dict      		=		disable_custom_kernels
           super().__init__(is_encoder_decoder=lowerCamelCase,      **lowerCamelCase)
       @property
       def 			UpperCamelCase     (					self)       ->   int:




           """simple docstring"""

           return self.encoder_attention_heads
       @property
       def 			UpperCamelCase     (					self)       ->   int:




           """simple docstring"""

           return self.d_model




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




           """simple docstring"""

           _lowercase       :							Union[str, Any]      		=		copy.deepcopy(self.__dict__)
           if self.backbone_config is not None:
               _lowercase       :							Union[str, Any]      		=		self.backbone_config.to_dict()
           _lowercase       :							Tuple      		=		self.__class__.model_type
           return output


