






'''simple docstring'''







from typing import Optional

import torch
import torch.utils.checkpoint
from torch import Tensor, nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import (
    BackboneOutput,
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import (
    add_code_sample_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    logging,
    replace_return_docstrings,
)
from ...utils.backbone_utils import BackboneMixin
from .configuration_resnet import ResNetConfig


__lowerCAmelCase									=   logging.get_logger(__name__)

# General docstring
__lowerCAmelCase									=   'ResNetConfig'

# Base docstring
__lowerCAmelCase									=   'microsoft/resnet-50'
__lowerCAmelCase									=   [1, 2_048, 7, 7]

# Image classification docstring
__lowerCAmelCase									=   'microsoft/resnet-50'
__lowerCAmelCase									=   'tiger cat'

__lowerCAmelCase									=   [
    'microsoft/resnet-50',
    # See all resnet models at https://huggingface.co/models?filter=resnet
]





class 						SCREAMING_SNAKE_CASE       (       nn.Module							):






			def __init__(			self   :      int	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int = 3	,    __SCREAMING_SNAKE_CASE   :      int = 1	,    __SCREAMING_SNAKE_CASE   :      str = "relu"       )      ->      int:
							super().__init__()
							a_		:	int									=   nn.Convad(
							    __SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    kernel_size=__SCREAMING_SNAKE_CASE	,    stride=__SCREAMING_SNAKE_CASE	,    padding=kernel_size // 2	,    bias=__SCREAMING_SNAKE_CASE       )
							a_		:	List[str]									=   nn.BatchNormad(__SCREAMING_SNAKE_CASE       )
							a_		:	Tuple									=   ACTaFN[activation] if activation is not None else nn.Identity()







			def       SCREAMING_SNAKE_CASE   (			self   :      int	,    __SCREAMING_SNAKE_CASE   :      Tensor       )      ->      Tensor:
							a_		:	Tuple									=   self.convolution(__SCREAMING_SNAKE_CASE       )
							a_		:	Union[str, Any]									=   self.normalization(__SCREAMING_SNAKE_CASE       )
							a_		:	Union[str, Any]									=   self.activation(__SCREAMING_SNAKE_CASE       )
							return hidden_state





class 						SCREAMING_SNAKE_CASE       (       nn.Module							):






			def __init__(			self   :      Union[str, Any]	,    __SCREAMING_SNAKE_CASE   :      ResNetConfig       )      ->      Any:
							super().__init__()
							a_		:	Tuple									=   ResNetConvLayer(
							    config.num_channels	,    config.embedding_size	,    kernel_size=7	,    stride=2	,    activation=config.hidden_act       )
							a_		:	Any									=   nn.MaxPoolad(kernel_size=3	,    stride=2	,    padding=1       )
							a_		:	int									=   config.num_channels







			def       SCREAMING_SNAKE_CASE   (			self   :      Tuple	,    __SCREAMING_SNAKE_CASE   :      Tensor       )      ->      Tensor:
							a_		:	str									=   pixel_values.shape[1]
							if num_channels != self.num_channels:
											raise ValueError(
											    '''Make sure that the channel dimension of the pixel values match with the one set in the configuration.'''       )
							a_		:	List[str]									=   self.embedder(__SCREAMING_SNAKE_CASE       )
							a_		:	Dict									=   self.pooler(__SCREAMING_SNAKE_CASE       )
							return embedding





class 						SCREAMING_SNAKE_CASE       (       nn.Module							):






			def __init__(			self   :      Any	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int = 2       )      ->      Any:
							super().__init__()
							a_		:	Any									=   nn.Convad(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    kernel_size=1	,    stride=__SCREAMING_SNAKE_CASE	,    bias=__SCREAMING_SNAKE_CASE       )
							a_		:	Tuple									=   nn.BatchNormad(__SCREAMING_SNAKE_CASE       )







			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[int]	,    __SCREAMING_SNAKE_CASE   :      Tensor       )      ->      Tensor:
							a_		:	List[str]									=   self.convolution(__SCREAMING_SNAKE_CASE       )
							a_		:	Optional[Any]									=   self.normalization(__SCREAMING_SNAKE_CASE       )
							return hidden_state





class 						SCREAMING_SNAKE_CASE       (       nn.Module							):






			def __init__(			self   :      Union[str, Any]	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int = 1	,    __SCREAMING_SNAKE_CASE   :      str = "relu"       )      ->      int:
							super().__init__()
							a_		:	Tuple									=   in_channels != out_channels or stride != 1
							a_		:	Optional[Any]									=   (
							    ResNetShortCut(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    stride=__SCREAMING_SNAKE_CASE       ) if should_apply_shortcut else nn.Identity()
							)
							a_		:	str									=   nn.Sequential(
							    ResNetConvLayer(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    stride=__SCREAMING_SNAKE_CASE       )	,    ResNetConvLayer(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    activation=__SCREAMING_SNAKE_CASE       )	,    )
							a_		:	int									=   ACTaFN[activation]







			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[int]	,    __SCREAMING_SNAKE_CASE   :      Optional[int]       )      ->      str:
							a_		:	int									=   hidden_state
							a_		:	Tuple									=   self.layer(__SCREAMING_SNAKE_CASE       )
							a_		:	Tuple									=   self.shortcut(__SCREAMING_SNAKE_CASE       )
							hidden_state += residual
							a_		:	List[str]									=   self.activation(__SCREAMING_SNAKE_CASE       )
							return hidden_state





class 						SCREAMING_SNAKE_CASE       (       nn.Module							):






			def __init__(			self   :      Optional[Any]	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int = 1	,    __SCREAMING_SNAKE_CASE   :      str = "relu"	,    __SCREAMING_SNAKE_CASE   :      int = 4       )      ->      Optional[Any]:
							super().__init__()
							a_		:	Optional[Any]									=   in_channels != out_channels or stride != 1
							a_		:	List[Any]									=   out_channels // reduction
							a_		:	List[str]									=   (
							    ResNetShortCut(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    stride=__SCREAMING_SNAKE_CASE       ) if should_apply_shortcut else nn.Identity()
							)
							a_		:	Dict									=   nn.Sequential(
							    ResNetConvLayer(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    kernel_size=1       )	,    ResNetConvLayer(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    stride=__SCREAMING_SNAKE_CASE       )	,    ResNetConvLayer(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    kernel_size=1	,    activation=__SCREAMING_SNAKE_CASE       )	,    )
							a_		:	Any									=   ACTaFN[activation]







			def       SCREAMING_SNAKE_CASE   (			self   :      str	,    __SCREAMING_SNAKE_CASE   :      str       )      ->      Optional[Any]:
							a_		:	Tuple									=   hidden_state
							a_		:	str									=   self.layer(__SCREAMING_SNAKE_CASE       )
							a_		:	Optional[int]									=   self.shortcut(__SCREAMING_SNAKE_CASE       )
							hidden_state += residual
							a_		:	int									=   self.activation(__SCREAMING_SNAKE_CASE       )
							return hidden_state





class 						SCREAMING_SNAKE_CASE       (       nn.Module							):






			def __init__(			self   :      Tuple	,    __SCREAMING_SNAKE_CASE   :      ResNetConfig	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int	,    __SCREAMING_SNAKE_CASE   :      int = 2	,    __SCREAMING_SNAKE_CASE   :      int = 2	,    )      ->      int:
							super().__init__()

							a_		:	Optional[Any]									=   ResNetBottleNeckLayer if config.layer_type == '''bottleneck''' else ResNetBasicLayer

							a_		:	str									=   nn.Sequential(
							    # downsampling is done in the first layer with stride of 2
							    layer(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    stride=__SCREAMING_SNAKE_CASE	,    activation=config.hidden_act       )	,    *[layer(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    activation=config.hidden_act       ) for _ in range(depth - 1       )]	,    )







			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[Any]	,    __SCREAMING_SNAKE_CASE   :      Tensor       )      ->      Tensor:
							a_		:	List[str]									=   input
							for layer in self.layers:
											a_		:	List[str]									=   layer(__SCREAMING_SNAKE_CASE       )
							return hidden_state





class 						SCREAMING_SNAKE_CASE       (       nn.Module							):






			def __init__(			self   :      Tuple	,    __SCREAMING_SNAKE_CASE   :      ResNetConfig       )      ->      str:
							super().__init__()
							a_		:	Optional[Any]									=   nn.ModuleList([]       )
							# based on `downsample_in_first_stage` the first layer of the first stage may or may not downsample the input
							self.stages.append(
							    ResNetStage(
							        __SCREAMING_SNAKE_CASE	,    config.embedding_size	,    config.hidden_sizes[0]	,    stride=2 if config.downsample_in_first_stage else 1	,    depth=config.depths[0]	,    )       )
							a_		:	Optional[int]									=   zip(config.hidden_sizes	,    config.hidden_sizes[1:]       )
							for (in_channels, out_channels), depth in zip(__SCREAMING_SNAKE_CASE	,    config.depths[1:]       ):
											self.stages.append(ResNetStage(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE	,    depth=__SCREAMING_SNAKE_CASE       )       )







			def       SCREAMING_SNAKE_CASE   (			self   :      Union[str, Any]	,    __SCREAMING_SNAKE_CASE   :      Tensor	,    __SCREAMING_SNAKE_CASE   :      bool = False	,    __SCREAMING_SNAKE_CASE   :      bool = True       )      ->      BaseModelOutputWithNoAttention:
							a_		:	Dict									=   () if output_hidden_states else None

							for stage_module in self.stages:
											if output_hidden_states:
															a_		:	Any									=   hidden_states + (hidden_state,)

											a_		:	Optional[Any]									=   stage_module(__SCREAMING_SNAKE_CASE       )

							if output_hidden_states:
											a_		:	List[Any]									=   hidden_states + (hidden_state,)

							if not return_dict:
											return tuple(v for v in [hidden_state, hidden_states] if v is not None       )

							return BaseModelOutputWithNoAttention(
							    last_hidden_state=__SCREAMING_SNAKE_CASE	,    hidden_states=__SCREAMING_SNAKE_CASE	,    )





class 						SCREAMING_SNAKE_CASE       (       SCREAMING_SNAKE_CASE_							):
			snake_case__	=					ResNetConfig
			snake_case__	=					"resnet"
			snake_case__	=					"pixel_values"
			snake_case__	=					True






			def       SCREAMING_SNAKE_CASE   (			self   :      Optional[int]	,    __SCREAMING_SNAKE_CASE   :      Any       )      ->      Dict:
							if isinstance(__SCREAMING_SNAKE_CASE	,    nn.Convad       ):
											nn.init.kaiming_normal_(module.weight	,    mode='''fan_out'''	,    nonlinearity='''relu'''       )
							elif isinstance(__SCREAMING_SNAKE_CASE	,    (nn.BatchNormad, nn.GroupNorm)       ):
											nn.init.constant_(module.weight	,    1       )
											nn.init.constant_(module.bias	,    0       )







			def       SCREAMING_SNAKE_CASE   (			self   :      str	,    __SCREAMING_SNAKE_CASE   :      str	,    __SCREAMING_SNAKE_CASE   :      Dict=False       )      ->      Any:
							if isinstance(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       ):
											a_		:	Union[str, Any]									=   value





__lowerCAmelCase									=   r'\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it\n    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n\n    Parameters:\n        config ([`ResNetConfig`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n'

__lowerCAmelCase									=   r'\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`ConvNextImageProcessor.__call__`] for details.\n\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.\n'





@add_start_docstrings(
    "The bare ResNet model outputting raw features without any specific head on top."						, SCREAMING_SNAKE_CASE_						, )
class 						SCREAMING_SNAKE_CASE       (       SCREAMING_SNAKE_CASE_							):






			def __init__(			self   :      Dict	,    __SCREAMING_SNAKE_CASE   :      Union[str, Any]       )      ->      List[Any]:
							super().__init__(__SCREAMING_SNAKE_CASE       )
							a_		:	List[Any]									=   config
							a_		:	Dict									=   ResNetEmbeddings(__SCREAMING_SNAKE_CASE       )
							a_		:	List[str]									=   ResNetEncoder(__SCREAMING_SNAKE_CASE       )
							a_		:	Tuple									=   nn.AdaptiveAvgPoolad((1, 1)       )
							# Initialize weights and apply final processing
							self.post_init()







			@add_start_docstrings_to_model_forward(__SCREAMING_SNAKE_CASE       )
			@add_code_sample_docstrings(
			    checkpoint=_CHECKPOINT_FOR_DOC	,    output_type=__SCREAMING_SNAKE_CASE	,    config_class=_CONFIG_FOR_DOC	,    modality='''vision'''	,    expected_output=_EXPECTED_OUTPUT_SHAPE	,    )
			def       SCREAMING_SNAKE_CASE   (			self   :      Dict	,    __SCREAMING_SNAKE_CASE   :      Tensor	,    __SCREAMING_SNAKE_CASE   :      Optional[bool] = None	,    __SCREAMING_SNAKE_CASE   :      Optional[bool] = None       )      ->      BaseModelOutputWithPoolingAndNoAttention:
							a_		:	Dict									=   (
							    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
							)
							a_		:	Any									=   return_dict if return_dict is not None else self.config.use_return_dict

							a_		:	Union[str, Any]									=   self.embedder(__SCREAMING_SNAKE_CASE       )

							a_		:	Optional[Any]									=   self.encoder(
							    __SCREAMING_SNAKE_CASE	,    output_hidden_states=__SCREAMING_SNAKE_CASE	,    return_dict=__SCREAMING_SNAKE_CASE       )

							a_		:	Any									=   encoder_outputs[0]

							a_		:	List[Any]									=   self.pooler(__SCREAMING_SNAKE_CASE       )

							if not return_dict:
											return (last_hidden_state, pooled_output) + encoder_outputs[1:]

							return BaseModelOutputWithPoolingAndNoAttention(
							    last_hidden_state=__SCREAMING_SNAKE_CASE	,    pooler_output=__SCREAMING_SNAKE_CASE	,    hidden_states=encoder_outputs.hidden_states	,    )





@add_start_docstrings(
    "\n    ResNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    "						, SCREAMING_SNAKE_CASE_						, )
class 						SCREAMING_SNAKE_CASE       (       SCREAMING_SNAKE_CASE_							):






			def __init__(			self   :      List[str]	,    __SCREAMING_SNAKE_CASE   :      Union[str, Any]       )      ->      List[Any]:
							super().__init__(__SCREAMING_SNAKE_CASE       )
							a_		:	List[Any]									=   config.num_labels
							a_		:	int									=   ResNetModel(__SCREAMING_SNAKE_CASE       )
							# classification head
							a_		:	List[Any]									=   nn.Sequential(
							    nn.Flatten()	,    nn.Linear(config.hidden_sizes[-1]	,    config.num_labels       ) if config.num_labels > 0 else nn.Identity()	,    )
							# initialize weights and apply final processing
							self.post_init()







			@add_start_docstrings_to_model_forward(__SCREAMING_SNAKE_CASE       )
			@add_code_sample_docstrings(
			    checkpoint=_IMAGE_CLASS_CHECKPOINT	,    output_type=__SCREAMING_SNAKE_CASE	,    config_class=_CONFIG_FOR_DOC	,    expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT	,    )
			def       SCREAMING_SNAKE_CASE   (			self   :      Dict	,    __SCREAMING_SNAKE_CASE   :      Optional[torch.FloatTensor] = None	,    __SCREAMING_SNAKE_CASE   :      Optional[torch.LongTensor] = None	,    __SCREAMING_SNAKE_CASE   :      Optional[bool] = None	,    __SCREAMING_SNAKE_CASE   :      Optional[bool] = None	,    )      ->      ImageClassifierOutputWithNoAttention:
							a_		:	Optional[int]									=   return_dict if return_dict is not None else self.config.use_return_dict

							a_		:	Tuple									=   self.resnet(__SCREAMING_SNAKE_CASE	,    output_hidden_states=__SCREAMING_SNAKE_CASE	,    return_dict=__SCREAMING_SNAKE_CASE       )

							a_		:	List[Any]									=   outputs.pooler_output if return_dict else outputs[1]

							a_		:	List[str]									=   self.classifier(__SCREAMING_SNAKE_CASE       )

							a_		:	List[Any]									=   None

							if labels is not None:
											if self.config.problem_type is None:
															if self.num_labels == 1:
																			a_		:	Optional[int]									=   '''regression'''
															elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
																			a_		:	List[Any]									=   '''single_label_classification'''
															else:
																			a_		:	Any									=   '''multi_label_classification'''
											if self.config.problem_type == "regression":
															a_		:	Dict									=   MSELoss()
															if self.num_labels == 1:
																			a_		:	Dict									=   loss_fct(logits.squeeze()	,    labels.squeeze()       )
															else:
																			a_		:	Dict									=   loss_fct(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )
											elif self.config.problem_type == "single_label_classification":
															a_		:	List[Any]									=   CrossEntropyLoss()
															a_		:	List[Any]									=   loss_fct(logits.view(-1	,    self.num_labels       )	,    labels.view(-1       )       )
											elif self.config.problem_type == "multi_label_classification":
															a_		:	List[str]									=   BCEWithLogitsLoss()
															a_		:	List[Any]									=   loss_fct(__SCREAMING_SNAKE_CASE	,    __SCREAMING_SNAKE_CASE       )

							if not return_dict:
											a_		:	Tuple									=   (logits,) + outputs[2:]
											return (loss,) + output if loss is not None else output

							return ImageClassifierOutputWithNoAttention(loss=__SCREAMING_SNAKE_CASE	,    logits=__SCREAMING_SNAKE_CASE	,    hidden_states=outputs.hidden_states       )





@add_start_docstrings(
    "\n    ResNet backbone, to be used with frameworks like DETR and MaskFormer.\n    "						, SCREAMING_SNAKE_CASE_						, )
class 						SCREAMING_SNAKE_CASE       (       SCREAMING_SNAKE_CASE_						, SCREAMING_SNAKE_CASE_							):






			def __init__(			self   :      int	,    __SCREAMING_SNAKE_CASE   :      List[Any]       )      ->      List[Any]:
							super().__init__(__SCREAMING_SNAKE_CASE       )
							super()._init_backbone(__SCREAMING_SNAKE_CASE       )

							a_		:	int									=   [config.embedding_size] + config.hidden_sizes
							a_		:	Any									=   ResNetEmbeddings(__SCREAMING_SNAKE_CASE       )
							a_		:	Union[str, Any]									=   ResNetEncoder(__SCREAMING_SNAKE_CASE       )

							# initialize weights and apply final processing
							self.post_init()







			@add_start_docstrings_to_model_forward(__SCREAMING_SNAKE_CASE       )
			@replace_return_docstrings(output_type=__SCREAMING_SNAKE_CASE	,    config_class=_CONFIG_FOR_DOC       )
			def       SCREAMING_SNAKE_CASE   (			self   :      str	,    __SCREAMING_SNAKE_CASE   :      Tensor	,    __SCREAMING_SNAKE_CASE   :      Optional[bool] = None	,    __SCREAMING_SNAKE_CASE   :      Optional[bool] = None       )      ->      BackboneOutput:
							a_		:	int									=   return_dict if return_dict is not None else self.config.use_return_dict
							a_		:	Union[str, Any]									=   (
							    output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
							)

							a_		:	Optional[int]									=   self.embedder(__SCREAMING_SNAKE_CASE       )

							a_		:	List[str]									=   self.encoder(__SCREAMING_SNAKE_CASE	,    output_hidden_states=__SCREAMING_SNAKE_CASE	,    return_dict=__SCREAMING_SNAKE_CASE       )

							a_		:	List[Any]									=   outputs.hidden_states

							a_		:	Tuple									=   ()
							for idx, stage in enumerate(self.stage_names       ):
											if stage in self.out_features:
															feature_maps += (hidden_states[idx],)

							if not return_dict:
											a_		:	List[Any]									=   (feature_maps,)
											if output_hidden_states:
															output += (outputs.hidden_states,)
											return output

							return BackboneOutput(
							    feature_maps=__SCREAMING_SNAKE_CASE	,    hidden_states=outputs.hidden_states if output_hidden_states else None	,    attentions=__SCREAMING_SNAKE_CASE	,    )












'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


__lowerCAmelCase									=   {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DeiTConfig', 'DeiTOnnxConfig']}

try:
		if not is_vision_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__lowerCAmelCase									=   ['DeiTFeatureExtractor']
		__lowerCAmelCase									=   ['DeiTImageProcessor']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__lowerCAmelCase									=   [
		    'DEIT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'DeiTForImageClassification',
		    'DeiTForImageClassificationWithTeacher',
		    'DeiTForMaskedImageModeling',
		    'DeiTModel',
		    'DeiTPreTrainedModel',
		]

try:
		if not is_tf_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__lowerCAmelCase									=   [
		    'TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST',
		    'TFDeiTForImageClassification',
		    'TFDeiTForImageClassificationWithTeacher',
		    'TFDeiTForMaskedImageModeling',
		    'TFDeiTModel',
		    'TFDeiTPreTrainedModel',
		]


if TYPE_CHECKING:
		from .configuration_deit import DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, DeiTConfig, DeiTOnnxConfig

		try:
				if not is_vision_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .feature_extraction_deit import DeiTFeatureExtractor
				from .image_processing_deit import DeiTImageProcessor

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_deit import (
				    DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    DeiTForImageClassification,
				    DeiTForImageClassificationWithTeacher,
				    DeiTForMaskedImageModeling,
				    DeiTModel,
				    DeiTPreTrainedModel,
				)

		try:
				if not is_tf_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_tf_deit import (
				    TF_DEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
				    TFDeiTForImageClassification,
				    TFDeiTForImageClassificationWithTeacher,
				    TFDeiTForMaskedImageModeling,
				    TFDeiTModel,
				    TFDeiTPreTrainedModel,
				)


else:
		import sys

		__lowerCAmelCase									=   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




