import os
import tempfile
import unittest

from transformers import FlaubertConfig, is_torch_available
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import (
        FlaubertForMultipleChoice,
        FlaubertForQuestionAnswering,
        FlaubertForQuestionAnsweringSimple,
        FlaubertForSequenceClassification,
        FlaubertForTokenClassification,
        FlaubertModel,
        FlaubertWithLMHeadModel,
    )
    from transformers.models.flaubert.modeling_flaubert import FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST


class 	lowerCamelCase_     (   UpperCAmelCase_ ):






    '''simple docstring'''






    def __init__(	self , __lowercase , __lowercase=13 , __lowercase=7 , __lowercase=True , __lowercase=True , __lowercase=True , __lowercase=True , __lowercase=True , __lowercase=False , __lowercase=False , __lowercase=False , __lowercase=2 , __lowercase=99 , __lowercase=0 , __lowercase=32 , __lowercase=5 , __lowercase=4 , __lowercase=0.1 , __lowercase=0.1 , __lowercase=512 , __lowercase=12 , __lowercase=2 , __lowercase=0.02 , __lowercase=3 , __lowercase=4 , __lowercase="last" , __lowercase=None , __lowercase=None , )       ->	Optional[Any]:
        __UpperCamelCase     :Union[str, Any]			  =		parent
        __UpperCamelCase     :Dict			  =		batch_size
        __UpperCamelCase     :Any			  =		seq_length
        __UpperCamelCase     :List[str]			  =		is_training
        __UpperCamelCase     :Dict			  =		use_input_lengths
        __UpperCamelCase     :Tuple			  =		use_token_type_ids
        __UpperCamelCase     :Union[str, Any]			  =		use_labels
        __UpperCamelCase     :Dict			  =		gelu_activation
        __UpperCamelCase     :int			  =		sinusoidal_embeddings
        __UpperCamelCase     :Optional[int]			  =		causal
        __UpperCamelCase     :int			  =		asm
        __UpperCamelCase     :Tuple			  =		n_langs
        __UpperCamelCase     :Optional[int]			  =		vocab_size
        __UpperCamelCase     :Tuple			  =		n_special
        __UpperCamelCase     :str			  =		hidden_size
        __UpperCamelCase     :int			  =		num_hidden_layers
        __UpperCamelCase     :int			  =		num_attention_heads
        __UpperCamelCase     :Optional[Any]			  =		hidden_dropout_prob
        __UpperCamelCase     :Union[str, Any]			  =		attention_probs_dropout_prob
        __UpperCamelCase     :Tuple			  =		max_position_embeddings
        __UpperCamelCase     :Dict			  =		type_vocab_size
        __UpperCamelCase     :Tuple			  =		type_sequence_label_size
        __UpperCamelCase     :List[Any]			  =		initializer_range
        __UpperCamelCase     :int			  =		num_labels
        __UpperCamelCase     :Optional[Any]			  =		num_choices
        __UpperCamelCase     :List[Any]			  =		summary_type
        __UpperCamelCase     :str			  =		use_proj
        __UpperCamelCase     :List[Any]			  =		scope







    def 			UpperCamelCase__   (	self)       ->	Optional[int]:
        __UpperCamelCase     :Dict			  =		ids_tensor([self.batch_size, self.seq_length] , self.vocab_size)
        __UpperCamelCase     :Any			  =		random_attention_mask([self.batch_size, self.seq_length])

        __UpperCamelCase     :Optional[Any]			  =		None
        if self.use_input_lengths:
            __UpperCamelCase     :str			  =		(
                ids_tensor([self.batch_size] , vocab_size=2) + self.seq_length - 2
            )  # small variation of seq_length

        __UpperCamelCase     :List[str]			  =		None
        if self.use_token_type_ids:
            __UpperCamelCase     :Any			  =		ids_tensor([self.batch_size, self.seq_length] , self.n_langs)

        __UpperCamelCase     :Optional[int]			  =		None
        __UpperCamelCase     :List[str]			  =		None
        __UpperCamelCase     :str			  =		None
        if self.use_labels:
            __UpperCamelCase     :int			  =		ids_tensor([self.batch_size] , self.type_sequence_label_size)
            __UpperCamelCase     :Union[str, Any]			  =		ids_tensor([self.batch_size, self.seq_length] , self.num_labels)
            __UpperCamelCase     :List[str]			  =		ids_tensor([self.batch_size] , 2).float()
            __UpperCamelCase     :Optional[Any]			  =		ids_tensor([self.batch_size] , self.num_choices)

        __UpperCamelCase     :Optional[Any]			  =		self.get_config()

        return (
            config,
            input_ids,
            token_type_ids,
            input_lengths,
            sequence_labels,
            token_labels,
            is_impossible_labels,
            choice_labels,
            input_mask,
        )







    def 			UpperCamelCase__   (	self)       ->	Optional[Any]:
        return FlaubertConfig(
            vocab_size=self.vocab_size , n_special=self.n_special , emb_dim=self.hidden_size , n_layers=self.num_hidden_layers , n_heads=self.num_attention_heads , dropout=self.hidden_dropout_prob , attention_dropout=self.attention_probs_dropout_prob , gelu_activation=self.gelu_activation , sinusoidal_embeddings=self.sinusoidal_embeddings , asm=self.asm , causal=self.causal , n_langs=self.n_langs , max_position_embeddings=self.max_position_embeddings , initializer_range=self.initializer_range , summary_type=self.summary_type , use_proj=self.use_proj , )







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , )       ->	Union[str, Any]:
        __UpperCamelCase     :Dict			  =		FlaubertModel(config=__lowercase)
        model.to(__lowercase)
        model.eval()
        __UpperCamelCase     :str			  =		model(__lowercase , lengths=__lowercase , langs=__lowercase)
        __UpperCamelCase     :Tuple			  =		model(__lowercase , langs=__lowercase)
        __UpperCamelCase     :Optional[Any]			  =		model(__lowercase)
        self.parent.assertEqual(result.last_hidden_state.shape , (self.batch_size, self.seq_length, self.hidden_size))







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , )       ->	List[str]:
        __UpperCamelCase     :Optional[int]			  =		FlaubertWithLMHeadModel(__lowercase)
        model.to(__lowercase)
        model.eval()

        __UpperCamelCase     :Optional[int]			  =		model(__lowercase , token_type_ids=__lowercase , labels=__lowercase)
        self.parent.assertEqual(result.loss.shape , ())
        self.parent.assertEqual(result.logits.shape , (self.batch_size, self.seq_length, self.vocab_size))







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , )       ->	int:
        __UpperCamelCase     :int			  =		FlaubertForQuestionAnsweringSimple(__lowercase)
        model.to(__lowercase)
        model.eval()

        __UpperCamelCase     :Union[str, Any]			  =		model(__lowercase)

        __UpperCamelCase     :Optional[int]			  =		model(__lowercase , start_positions=__lowercase , end_positions=__lowercase)
        self.parent.assertEqual(result.start_logits.shape , (self.batch_size, self.seq_length))
        self.parent.assertEqual(result.end_logits.shape , (self.batch_size, self.seq_length))







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , )       ->	Tuple:
        __UpperCamelCase     :Tuple			  =		FlaubertForQuestionAnswering(__lowercase)
        model.to(__lowercase)
        model.eval()

        __UpperCamelCase     :Union[str, Any]			  =		model(__lowercase)

        __UpperCamelCase     :Dict			  =		model(
            __lowercase , start_positions=__lowercase , end_positions=__lowercase , cls_index=__lowercase , is_impossible=__lowercase , p_mask=__lowercase , )

        __UpperCamelCase     :int			  =		model(
            __lowercase , start_positions=__lowercase , end_positions=__lowercase , cls_index=__lowercase , is_impossible=__lowercase , )

        ((__UpperCamelCase)  ,       )     :Dict			  =		result_with_labels.to_tuple()

        __UpperCamelCase     :Union[str, Any]			  =		model(__lowercase , start_positions=__lowercase , end_positions=__lowercase)

        ((__UpperCamelCase)  ,       )     :Any			  =		result_with_labels.to_tuple()

        self.parent.assertEqual(result_with_labels.loss.shape , ())
        self.parent.assertEqual(result.start_top_log_probs.shape , (self.batch_size, model.config.start_n_top))
        self.parent.assertEqual(result.start_top_index.shape , (self.batch_size, model.config.start_n_top))
        self.parent.assertEqual(
            result.end_top_log_probs.shape , (self.batch_size, model.config.start_n_top * model.config.end_n_top))
        self.parent.assertEqual(
            result.end_top_index.shape , (self.batch_size, model.config.start_n_top * model.config.end_n_top))
        self.parent.assertEqual(result.cls_logits.shape , (self.batch_size,))







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , )       ->	Any:
        __UpperCamelCase     :int			  =		FlaubertForSequenceClassification(__lowercase)
        model.to(__lowercase)
        model.eval()

        __UpperCamelCase     :Union[str, Any]			  =		model(__lowercase)
        __UpperCamelCase     :List[Any]			  =		model(__lowercase , labels=__lowercase)

        self.parent.assertEqual(result.loss.shape , ())
        self.parent.assertEqual(result.logits.shape , (self.batch_size, self.type_sequence_label_size))







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , )       ->	Optional[int]:
        __UpperCamelCase     :Union[str, Any]			  =		self.num_labels
        __UpperCamelCase     :List[str]			  =		FlaubertForTokenClassification(__lowercase)
        model.to(__lowercase)
        model.eval()

        __UpperCamelCase     :Any			  =		model(__lowercase , attention_mask=__lowercase , labels=__lowercase)
        self.parent.assertEqual(result.logits.shape , (self.batch_size, self.seq_length, self.num_labels))







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase , )       ->	Dict:
        __UpperCamelCase     :List[str]			  =		self.num_choices
        __UpperCamelCase     :int			  =		FlaubertForMultipleChoice(config=__lowercase)
        model.to(__lowercase)
        model.eval()
        __UpperCamelCase     :Any			  =		input_ids.unsqueeze(1).expand(-1 , self.num_choices , -1).contiguous()
        __UpperCamelCase     :Tuple			  =		token_type_ids.unsqueeze(1).expand(-1 , self.num_choices , -1).contiguous()
        __UpperCamelCase     :Dict			  =		input_mask.unsqueeze(1).expand(-1 , self.num_choices , -1).contiguous()
        __UpperCamelCase     :int			  =		model(
            __lowercase , attention_mask=__lowercase , token_type_ids=__lowercase , labels=__lowercase , )
        self.parent.assertEqual(result.logits.shape , (self.batch_size, self.num_choices))







    def 			UpperCamelCase__   (	self)       ->	List[Any]:
        __UpperCamelCase     :Union[str, Any]			  =		self.prepare_config_and_inputs()
        (
            (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       (
            __UpperCamelCase
        )  ,       
        )     :int			  =		config_and_inputs
        __UpperCamelCase     :List[Any]			  =		{
            '''input_ids''': input_ids,
            '''token_type_ids''': token_type_ids,
            '''lengths''': input_lengths,
            '''attention_mask''': input_mask,
        }
        return config, inputs_dict


@require_torch
class 	lowerCamelCase_     (   UpperCAmelCase_						,	UpperCAmelCase_						,	unittest.TestCase ):






    '''simple docstring'''






    a__	:						Dict						=      (
        (
            FlaubertModel,
            FlaubertWithLMHeadModel,
            FlaubertForQuestionAnswering,
            FlaubertForQuestionAnsweringSimple,
            FlaubertForSequenceClassification,
            FlaubertForTokenClassification,
            FlaubertForMultipleChoice,
        )
        if is_torch_available()
        else ()
    )
    a__	:						Optional[int]						=      (
        {
            """feature-extraction""": FlaubertModel,
            """fill-mask""": FlaubertWithLMHeadModel,
            """question-answering""": FlaubertForQuestionAnsweringSimple,
            """text-classification""": FlaubertForSequenceClassification,
            """token-classification""": FlaubertForTokenClassification,
            """zero-shot""": FlaubertForSequenceClassification,
        }
        if is_torch_available()
        else {}
    )







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase , __lowercase , __lowercase)       ->	Tuple:
        if (
            pipeline_test_casse_name == "QAPipelineTests"
            and tokenizer_name is not None
            and not tokenizer_name.endswith('''Fast''')
        ):
            # `QAPipelineTests` fails for a few models when the slower tokenizer are used.
            # (The slower tokenizers were never used for pipeline tests before the pipeline testing rework)
            # TODO: check (and possibly fix) the `QAPipelineTests` with slower tokenizer
            return True

        return False







    def 			UpperCamelCase__   (	self , __lowercase , __lowercase , __lowercase=False)       ->	int:
        __UpperCamelCase     :Union[str, Any]			  =		super()._prepare_for_class(__lowercase , __lowercase , return_labels=__lowercase)

        if return_labels:
            if model_class.__name__ == "FlaubertForQuestionAnswering":
                __UpperCamelCase     :Tuple			  =		torch.zeros(
                    self.model_tester.batch_size , dtype=torch.long , device=__lowercase)
                __UpperCamelCase     :Optional[int]			  =		torch.zeros(
                    self.model_tester.batch_size , dtype=torch.long , device=__lowercase)

        return inputs_dict







    def 			UpperCamelCase__   (	self)       ->	Any:
        __UpperCamelCase     :Optional[Any]			  =		FlaubertModelTester(self)
        __UpperCamelCase     :Any			  =		ConfigTester(self , config_class=__lowercase , emb_dim=37)







    def 			UpperCamelCase__   (	self)       ->	Optional[Any]:
        self.config_tester.run_common_tests()







    def 			UpperCamelCase__   (	self)       ->	int:
        __UpperCamelCase     :List[str]			  =		self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_flaubert_model(*__lowercase)







    def 			UpperCamelCase__   (	self)       ->	int:
        __UpperCamelCase     :Optional[Any]			  =		self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_flaubert_lm_head(*__lowercase)







    def 			UpperCamelCase__   (	self)       ->	List[str]:
        __UpperCamelCase     :Optional[int]			  =		self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_flaubert_simple_qa(*__lowercase)







    def 			UpperCamelCase__   (	self)       ->	Dict:
        __UpperCamelCase     :List[Any]			  =		self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_flaubert_qa(*__lowercase)







    def 			UpperCamelCase__   (	self)       ->	List[str]:
        __UpperCamelCase     :Optional[Any]			  =		self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_flaubert_sequence_classif(*__lowercase)







    def 			UpperCamelCase__   (	self)       ->	str:
        __UpperCamelCase     :List[str]			  =		self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_flaubert_token_classif(*__lowercase)







    def 			UpperCamelCase__   (	self)       ->	List[str]:
        __UpperCamelCase     :Tuple			  =		self.model_tester.prepare_config_and_inputs()
        self.model_tester.create_and_check_flaubert_multiple_choice(*__lowercase)







    @slow
    def 			UpperCamelCase__   (	self)       ->	Any:
        for model_name in FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
            __UpperCamelCase     :Tuple			  =		FlaubertModel.from_pretrained(__lowercase)
            self.assertIsNotNone(__lowercase)







    @slow
    @require_torch_gpu
    def 			UpperCamelCase__   (	self)       ->	Optional[int]:
        __UpperCamelCase  ,       __UpperCamelCase     :str			  =		self.model_tester.prepare_config_and_inputs_for_common()
        for model_class in self.all_model_classes:
            # FlauBertForMultipleChoice behaves incorrectly in JIT environments.
            if model_class == FlaubertForMultipleChoice:
                return

            __UpperCamelCase     :int			  =		True
            __UpperCamelCase     :List[str]			  =		model_class(config=__lowercase)

            __UpperCamelCase     :Dict			  =		self._prepare_for_class(__lowercase , __lowercase)
            __UpperCamelCase     :List[str]			  =		torch.jit.trace(
                __lowercase , (inputs_dict['''input_ids'''].to('''cpu'''), inputs_dict['''attention_mask'''].to('''cpu''')))

            with tempfile.TemporaryDirectory() as tmp:
                torch.jit.save(__lowercase , os.path.join(__lowercase , '''traced_model.pt'''))
                __UpperCamelCase     :Optional[Any]			  =		torch.jit.load(os.path.join(__lowercase , '''traced_model.pt''') , map_location=__lowercase)
                loaded(inputs_dict['''input_ids'''].to(__lowercase) , inputs_dict['''attention_mask'''].to(__lowercase))


@require_torch
class 	lowerCamelCase_     (   unittest.TestCase ):






    '''simple docstring'''






    @slow
    def 			UpperCamelCase__   (	self)       ->	Any:
        __UpperCamelCase     :List[Any]			  =		FlaubertModel.from_pretrained('''flaubert/flaubert_base_cased''')
        __UpperCamelCase     :Tuple			  =		torch.tensor([[0, 345, 232, 328, 740, 140, 1_695, 69, 6_078, 1_588, 2]])
        with torch.no_grad():
            __UpperCamelCase     :str			  =		model(__lowercase)[0]
        __UpperCamelCase     :Optional[Any]			  =		torch.Size((1, 11, 768))
        self.assertEqual(output.shape , __lowercase)
        __UpperCamelCase     :Dict			  =		torch.tensor(
            [[[-2.62_51, -1.42_98, -0.02_27], [-2.85_10, -1.63_87, 0.22_58], [-2.81_14, -1.18_32, -0.30_66]]])

        self.assertTrue(torch.allclose(output[:, :3, :3] , __lowercase , atol=1E-4))






import copy

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


__lowercase							 =					logging.get_logger(__name__)

__lowercase							 =					{
    '''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_     (   UpperCAmelCase_ ):






    '''simple docstring'''






    a__	:						List[str]						=      """deformable_detr"""
    a__	:						Union[str, Any]						=      {
        """hidden_size""": """d_model""",
        """num_attention_heads""": """encoder_attention_heads""",
    }







    def __init__(	self , __lowercase=True , __lowercase=None , __lowercase=3 , __lowercase=300 , __lowercase=1_024 , __lowercase=6 , __lowercase=1_024 , __lowercase=8 , __lowercase=6 , __lowercase=1_024 , __lowercase=8 , __lowercase=0.0 , __lowercase=True , __lowercase="relu" , __lowercase=256 , __lowercase=0.1 , __lowercase=0.0 , __lowercase=0.0 , __lowercase=0.02 , __lowercase=1.0 , __lowercase=True , __lowercase=False , __lowercase="sine" , __lowercase="resnet50" , __lowercase=True , __lowercase=False , __lowercase=4 , __lowercase=4 , __lowercase=4 , __lowercase=False , __lowercase=300 , __lowercase=False , __lowercase=1 , __lowercase=5 , __lowercase=2 , __lowercase=1 , __lowercase=1 , __lowercase=5 , __lowercase=2 , __lowercase=0.1 , __lowercase=0.25 , __lowercase=False , **__lowercase , )       ->	int:
        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.''')
                __UpperCamelCase     :str			  =		CONFIG_MAPPING['''resnet'''](out_features=['''stage4'''])
            elif isinstance(__lowercase , __lowercase):
                __UpperCamelCase     :str			  =		backbone_config.get('''model_type''')
                __UpperCamelCase     :Tuple			  =		CONFIG_MAPPING[backbone_model_type]
                __UpperCamelCase     :Any			  =		config_class.from_dict(__lowercase)
        __UpperCamelCase     :int			  =		use_timm_backbone
        __UpperCamelCase     :Dict			  =		backbone_config
        __UpperCamelCase     :Any			  =		num_channels
        __UpperCamelCase     :Optional[int]			  =		num_queries
        __UpperCamelCase     :Any			  =		max_position_embeddings
        __UpperCamelCase     :str			  =		d_model
        __UpperCamelCase     :Tuple			  =		encoder_ffn_dim
        __UpperCamelCase     :Union[str, Any]			  =		encoder_layers
        __UpperCamelCase     :List[Any]			  =		encoder_attention_heads
        __UpperCamelCase     :Any			  =		decoder_ffn_dim
        __UpperCamelCase     :List[str]			  =		decoder_layers
        __UpperCamelCase     :int			  =		decoder_attention_heads
        __UpperCamelCase     :str			  =		dropout
        __UpperCamelCase     :Any			  =		attention_dropout
        __UpperCamelCase     :int			  =		activation_dropout
        __UpperCamelCase     :List[Any]			  =		activation_function
        __UpperCamelCase     :List[Any]			  =		init_std
        __UpperCamelCase     :List[Any]			  =		init_xavier_std
        __UpperCamelCase     :int			  =		encoder_layerdrop
        __UpperCamelCase     :str			  =		auxiliary_loss
        __UpperCamelCase     :Optional[Any]			  =		position_embedding_type
        __UpperCamelCase     :Union[str, Any]			  =		backbone
        __UpperCamelCase     :Any			  =		use_pretrained_backbone
        __UpperCamelCase     :str			  =		dilation
        # deformable attributes
        __UpperCamelCase     :Optional[Any]			  =		num_feature_levels
        __UpperCamelCase     :str			  =		encoder_n_points
        __UpperCamelCase     :int			  =		decoder_n_points
        __UpperCamelCase     :Union[str, Any]			  =		two_stage
        __UpperCamelCase     :Optional[Any]			  =		two_stage_num_proposals
        __UpperCamelCase     :Dict			  =		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
        __UpperCamelCase     :Optional[int]			  =		class_cost
        __UpperCamelCase     :List[Any]			  =		bbox_cost
        __UpperCamelCase     :str			  =		giou_cost
        # Loss coefficients
        __UpperCamelCase     :Tuple			  =		mask_loss_coefficient
        __UpperCamelCase     :Tuple			  =		dice_loss_coefficient
        __UpperCamelCase     :int			  =		bbox_loss_coefficient
        __UpperCamelCase     :Any			  =		giou_loss_coefficient
        __UpperCamelCase     :Dict			  =		eos_coefficient
        __UpperCamelCase     :Optional[Any]			  =		focal_alpha
        __UpperCamelCase     :Optional[Any]			  =		disable_custom_kernels
        super().__init__(is_encoder_decoder=__lowercase , **__lowercase)







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







    @property
    def 			UpperCamelCase__   (	self)       ->	int:
        return self.d_model







    def 			UpperCamelCase__   (	self)       ->	List[Any]:
        __UpperCamelCase     :Dict			  =		copy.deepcopy(self.__dict__)
        if self.backbone_config is not None:
            __UpperCamelCase     :Tuple			  =		self.backbone_config.to_dict()
        __UpperCamelCase     :List[Any]			  =		self.__class__.model_type
        return output





