

import copy
from collections import OrderedDict
from typing import Dict, Mapping

from packaging import version

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


a_     =			logging.get_logger(__name__)

a_     =			{
    'facebook/detr-resnet-50': 'https://huggingface.co/facebook/detr-resnet-50/resolve/main/config.json',
    # See all DETR models at https://huggingface.co/models?filter=detr
}






class _UpperCamelCase							(							__A      ):
			'''simple docstring'''







			lowerCamelCase__							='detr'
			lowerCamelCase__							=['past_key_values']
			lowerCamelCase__							={
			    'hidden_size': 'd_model',
			    'num_attention_heads': 'encoder_attention_heads',
			}
			def __init__(	self							:       Optional[int]					,					a							:       str=True					,					a							:       Union[str, Any]=None					,					a							:       Optional[int]=3					,					a							:       str=100					,					a							:       Tuple=6					,					a							:       str=2048					,					a							:       int=8					,					a							:       List[str]=6					,					a							:       Optional[Any]=2048					,					a							:       List[str]=8					,					a							:       Tuple=0.0					,					a							:       str=0.0					,					a							:       List[str]=True					,					a							:       Optional[Any]="relu"					,					a							:       Optional[int]=256					,					a							:       Optional[int]=0.1					,					a							:       Tuple=0.0					,					a							:       Tuple=0.0					,					a							:       Tuple=0.02					,					a							:       int=1.0					,					a							:       Any=False					,					a							:       Union[str, Any]="sine"					,					a							:       str="resnet50"					,					a							:       Any=True					,					a							:       Union[str, Any]=False					,					a							:       Tuple=1					,					a							:       Union[str, Any]=5					,					a							:       Dict=2					,					a							:       int=1					,					a							:       List[str]=1					,					a							:       List[str]=5					,					a							:       Tuple=2					,					a							:       Tuple=0.1					,					**a							:       Optional[int]					,					)							->				Tuple:

				"""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."		)
						SCREAMING_SNAKE_CASE      :					Any    =				CONFIG_MAPPING["resnet"](out_features=["stage4"]		)
					elif isinstance(__UpperCAmelCase					,					__UpperCAmelCase		):
						SCREAMING_SNAKE_CASE      :					Tuple    =				backbone_config.get("model_type"		)
						SCREAMING_SNAKE_CASE      :					Union[str, Any]    =				CONFIG_MAPPING[backbone_model_type]
						SCREAMING_SNAKE_CASE      :					str    =				config_class.from_dict(__UpperCAmelCase		)
					# set timm attributes to None
					SCREAMING_SNAKE_CASE   ,SCREAMING_SNAKE_CASE   ,SCREAMING_SNAKE_CASE      :					Union[str, Any]    =				None, None, None

				SCREAMING_SNAKE_CASE      :					Optional[int]    =				use_timm_backbone
				SCREAMING_SNAKE_CASE      :					Union[str, Any]    =				backbone_config
				SCREAMING_SNAKE_CASE      :					int    =				num_channels
				SCREAMING_SNAKE_CASE      :					Union[str, Any]    =				num_queries
				SCREAMING_SNAKE_CASE      :					str    =				d_model
				SCREAMING_SNAKE_CASE      :					Optional[int]    =				encoder_ffn_dim
				SCREAMING_SNAKE_CASE      :					int    =				encoder_layers
				SCREAMING_SNAKE_CASE      :					Dict    =				encoder_attention_heads
				SCREAMING_SNAKE_CASE      :					List[str]    =				decoder_ffn_dim
				SCREAMING_SNAKE_CASE      :					Union[str, Any]    =				decoder_layers
				SCREAMING_SNAKE_CASE      :					str    =				decoder_attention_heads
				SCREAMING_SNAKE_CASE      :					Any    =				dropout
				SCREAMING_SNAKE_CASE      :					Optional[int]    =				attention_dropout
				SCREAMING_SNAKE_CASE      :					List[Any]    =				activation_dropout
				SCREAMING_SNAKE_CASE      :					List[Any]    =				activation_function
				SCREAMING_SNAKE_CASE      :					List[Any]    =				init_std
				SCREAMING_SNAKE_CASE      :					Tuple    =				init_xavier_std
				SCREAMING_SNAKE_CASE      :					Dict    =				encoder_layerdrop
				SCREAMING_SNAKE_CASE      :					Optional[int]    =				decoder_layerdrop
				SCREAMING_SNAKE_CASE      :					Optional[Any]    =				encoder_layers
				SCREAMING_SNAKE_CASE      :					List[Any]    =				auxiliary_loss
				SCREAMING_SNAKE_CASE      :					int    =				position_embedding_type
				SCREAMING_SNAKE_CASE      :					Tuple    =				backbone
				SCREAMING_SNAKE_CASE      :					int    =				use_pretrained_backbone
				SCREAMING_SNAKE_CASE      :					Dict    =				dilation
				# Hungarian matcher
				SCREAMING_SNAKE_CASE      :					Any    =				class_cost
				SCREAMING_SNAKE_CASE      :					int    =				bbox_cost
				SCREAMING_SNAKE_CASE      :					int    =				giou_cost
				# Loss coefficients
				SCREAMING_SNAKE_CASE      :					Any    =				mask_loss_coefficient
				SCREAMING_SNAKE_CASE      :					List[str]    =				dice_loss_coefficient
				SCREAMING_SNAKE_CASE      :					List[str]    =				bbox_loss_coefficient
				SCREAMING_SNAKE_CASE      :					Tuple    =				giou_loss_coefficient
				SCREAMING_SNAKE_CASE      :					Optional[Any]    =				eos_coefficient
				super().__init__(is_encoder_decoder=__UpperCAmelCase					,					**__UpperCAmelCase		)
			@property
			def 							__UpperCamelCase       (	self							:       Optional[Any]		)							->				int:

				"""simple docstring"""

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

				"""simple docstring"""

				return self.d_model
			@classmethod
			def 							__UpperCamelCase       (	cls							:       Union[str, Any]					,					a							:       Optional[int]					,					**a							:       Optional[Any]		)							->				Optional[int]:

				"""simple docstring"""

				return cls(backbone_config=__UpperCAmelCase					,					**__UpperCAmelCase		)






			def 							__UpperCamelCase       (	self							:       List[str]		)							->				Dict[str, any]:

				"""simple docstring"""

				SCREAMING_SNAKE_CASE      :					Optional[int]    =				copy.deepcopy(self.__dict__		)
				if output["backbone_config"] is not None:
					SCREAMING_SNAKE_CASE      :					Any    =				self.backbone_config.to_dict()
				SCREAMING_SNAKE_CASE      :					Tuple    =				self.__class__.model_type
				return output






class _UpperCamelCase							(							__A      ):
			'''simple docstring'''







			lowerCamelCase__							=version.parse('1.11'      )
			@property
			def 							__UpperCamelCase       (	self							:       Any		)							->				Mapping[str, Mapping[int, str]]:

				"""simple docstring"""

				return OrderedDict(
				    [
				        ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
				        ("pixel_mask", {0: "batch"}),
				    ]		)
			@property
			def 							__UpperCamelCase       (	self							:       int		)							->				float:

				"""simple docstring"""

				return 1e-5






			@property
			def 							__UpperCamelCase       (	self							:       Dict		)							->				int:

				"""simple docstring"""

				return 12
"""simple docstring"""




# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


__lowerCamelCase							 =     {
    "configuration_vivit": ["VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "VivitConfig"],
}
try:
				if not is_vision_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCamelCase							 =     ["VivitImageProcessor"]


try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				__lowerCamelCase							 =     [
				    "VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST",
				    "VivitModel",
				    "VivitPreTrainedModel",
				    "VivitForVideoClassification",
				]


if TYPE_CHECKING:
				from .configuration_vivit import VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, VivitConfig

				try:
								if not is_vision_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .image_processing_vivit import VivitImageProcessor

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_vivit import (
								    VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    VivitForVideoClassification,
								    VivitModel,
								    VivitPreTrainedModel,
								)


else:
				import sys

				__lowerCamelCase							 =     _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





