

from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


lowercase_             =     logging.get_logger(__name__)

lowercase_             =     {
    'microsoft/resnet-50': 'https://huggingface.co/microsoft/resnet-50/blob/main/config.json',
}





class 				__lowerCAmelCase  (      _a    ,    _a							):
  _a		    =						"""resnet"""
  _a		    =						["""basic""", """bottleneck"""]




  def __init__(       self							,     lowerCAmelCase=3							,     lowerCAmelCase=64							,     lowerCAmelCase=[256, 512, 1_024, 2_048]							,     lowerCAmelCase=[3, 4, 6, 3]							,     lowerCAmelCase="bottleneck"							,     lowerCAmelCase="relu"							,     lowerCAmelCase=False							,     lowerCAmelCase=None							,     lowerCAmelCase=None							,     **lowerCAmelCase							,     )						->				Union[str, Any]:
        '''simple docstring'''






        super().__init__(**_A      )
        if layer_type not in self.layer_types:
              raise ValueError(F'''layer_type={layer_type} is not one of {",".join(self.layer_types      )}'''      )
        _lowercase			 =num_channels
        _lowercase			 =embedding_size
        _lowercase			 =hidden_sizes
        _lowercase			 =depths
        _lowercase			 =layer_type
        _lowercase			 =hidden_act
        _lowercase			 =downsample_in_first_stage
        _lowercase			 =['stem'] + [F'''stage{idx}''' for idx in range(1							,     len(_A      ) + 1      )]
        _lowercase , _lowercase			 =get_aligned_output_features_output_indices(
            out_features=_A							,     out_indices=_A							,     stage_names=self.stage_names      )





class 				__lowerCAmelCase  (      _a							):
  _a		    =						version.parse("""1.11"""							)




  @property
  def 						A__  (       self      )						->				Optional[int]:
        '''simple docstring'''






        return OrderedDict(
            [
                ('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'}),
            ]      )




  @property
  def 						A__  (       self      )						->				Optional[int]:
        '''simple docstring'''






        return 1e-3





from typing import TYPE_CHECKING

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


lowercase_             =     {'configuration_beit': ['BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BeitConfig', 'BeitOnnxConfig']}

try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_             =     ['BeitFeatureExtractor']
  lowercase_             =     ['BeitImageProcessor']

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_             =     [
      'BEIT_PRETRAINED_MODEL_ARCHIVE_LIST',
      'BeitForImageClassification',
      'BeitForMaskedImageModeling',
      'BeitForSemanticSegmentation',
      'BeitModel',
      'BeitPreTrainedModel',
  ]


try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_             =     [
      'FlaxBeitForImageClassification',
      'FlaxBeitForMaskedImageModeling',
      'FlaxBeitModel',
      'FlaxBeitPreTrainedModel',
  ]

if TYPE_CHECKING:
  from .configuration_beit import BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP, BeitConfig, BeitOnnxConfig

  try:
    if not is_vision_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .feature_extraction_beit import BeitFeatureExtractor
    from .image_processing_beit import BeitImageProcessor

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_beit import (
        BEIT_PRETRAINED_MODEL_ARCHIVE_LIST,
        BeitForImageClassification,
        BeitForMaskedImageModeling,
        BeitForSemanticSegmentation,
        BeitModel,
        BeitPreTrainedModel,
    )

  try:
    if not is_flax_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_flax_beit import (
        FlaxBeitForImageClassification,
        FlaxBeitForMaskedImageModeling,
        FlaxBeitModel,
        FlaxBeitPreTrainedModel,
    )


else:
  import sys

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


