






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	:							List[Any]				=logging.get_logger(__name__)

# General docstring
lowerCamelCase	:							List[str]				='''ResNetConfig'''

# Base docstring
lowerCamelCase	:							Optional[Any]				='''microsoft/resnet-50'''
lowerCamelCase	:							Optional[Any]				=[1, 2048, 7, 7]

# Image classification docstring
lowerCamelCase	:							Optional[Any]				='''microsoft/resnet-50'''
lowerCamelCase	:							int				='''tiger cat'''

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





class 			__a  (    nn.Module       ):







 def __init__(		self					:   List[Any]							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int = 3							,   SCREAMING_SNAKE_CASE					:   int = 1							,   SCREAMING_SNAKE_CASE					:   str = "relu"						):


      '''simple docstring'''






      super().__init__()
      UpperCamelCase__			:   List[Any]       				=  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						)
      UpperCamelCase__			:   Tuple       				=  nn.BatchNormad(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   int       				=  ACTaFN[activation] if activation is not None else nn.Identity()







 def 					__lowercase					(		self					:   Tuple							,   SCREAMING_SNAKE_CASE					:   Tensor						):


      '''simple docstring'''






      UpperCamelCase__			:   Optional[int]       				=  self.convolution(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Any       				=  self.normalization(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Union[str, Any]       				=  self.activation(SCREAMING_SNAKE_CASE						)
      return hidden_state







class 			__a  (    nn.Module       ):







 def __init__(		self					:   Union[str, Any]							,   SCREAMING_SNAKE_CASE					:   ResNetConfig						):


      '''simple docstring'''






      super().__init__()
      UpperCamelCase__			:   Union[str, Any]       				=  ResNetConvLayer(
          config.num_channels							,   config.embedding_size							,   kernel_size=7							,   stride=2							,   activation=config.hidden_act						)
      UpperCamelCase__			:   List[Any]       				=  nn.MaxPoolad(kernel_size=3							,   stride=2							,   padding=1						)
      UpperCamelCase__			:   int       				=  config.num_channels







 def 					__lowercase					(		self					:   str							,   SCREAMING_SNAKE_CASE					:   Tensor						):


      '''simple docstring'''






      UpperCamelCase__			:   int       				=  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."						)
      UpperCamelCase__			:   Union[str, Any]       				=  self.embedder(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Union[str, Any]       				=  self.pooler(SCREAMING_SNAKE_CASE						)
      return embedding







class 			__a  (    nn.Module       ):







 def __init__(		self					:   int							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int = 2						):


      '''simple docstring'''






      super().__init__()
      UpperCamelCase__			:   Optional[int]       				=  nn.Convad(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE							,   kernel_size=1							,   stride=SCREAMING_SNAKE_CASE							,   bias=SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   List[str]       				=  nn.BatchNormad(SCREAMING_SNAKE_CASE						)







 def 					__lowercase					(		self					:   Any							,   SCREAMING_SNAKE_CASE					:   Tensor						):


      '''simple docstring'''






      UpperCamelCase__			:   List[str]       				=  self.convolution(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Dict       				=  self.normalization(SCREAMING_SNAKE_CASE						)
      return hidden_state







class 			__a  (    nn.Module       ):







 def __init__(		self					:   Dict							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int = 1							,   SCREAMING_SNAKE_CASE					:   str = "relu"						):


      '''simple docstring'''






      super().__init__()
      UpperCamelCase__			:   List[Any]       				=  in_channels != out_channels or stride != 1
      UpperCamelCase__			:   str       				=  (
          ResNetShortCut(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE							,   stride=SCREAMING_SNAKE_CASE						) if should_apply_shortcut else nn.Identity()
      )
      UpperCamelCase__			:   Any       				=  nn.Sequential(
          ResNetConvLayer(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE							,   stride=SCREAMING_SNAKE_CASE						)							,   ResNetConvLayer(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE							,   activation=SCREAMING_SNAKE_CASE						)							,   )
      UpperCamelCase__			:   List[str]       				=  ACTaFN[activation]







 def 					__lowercase					(		self					:   Optional[Any]							,   SCREAMING_SNAKE_CASE					:   str						):


      '''simple docstring'''






      UpperCamelCase__			:   Optional[int]       				=  hidden_state
      UpperCamelCase__			:   Tuple       				=  self.layer(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Union[str, Any]       				=  self.shortcut(SCREAMING_SNAKE_CASE						)
      hidden_state += residual
      UpperCamelCase__			:   List[str]       				=  self.activation(SCREAMING_SNAKE_CASE						)
      return hidden_state







class 			__a  (    nn.Module       ):







 def __init__(		self					:   int							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int							,   SCREAMING_SNAKE_CASE					:   int = 1							,   SCREAMING_SNAKE_CASE					:   str = "relu"							,   SCREAMING_SNAKE_CASE					:   int = 4						):


      '''simple docstring'''






      super().__init__()
      UpperCamelCase__			:   Union[str, Any]       				=  in_channels != out_channels or stride != 1
      UpperCamelCase__			:   Union[str, Any]       				=  out_channels // reduction
      UpperCamelCase__			:   Union[str, Any]       				=  (
          ResNetShortCut(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE							,   stride=SCREAMING_SNAKE_CASE						) if should_apply_shortcut else nn.Identity()
      )
      UpperCamelCase__			:   Optional[Any]       				=  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						)							,   )
      UpperCamelCase__			:   Any       				=  ACTaFN[activation]







 def 					__lowercase					(		self					:   Optional[Any]							,   SCREAMING_SNAKE_CASE					:   Optional[int]						):


      '''simple docstring'''






      UpperCamelCase__			:   Dict       				=  hidden_state
      UpperCamelCase__			:   str       				=  self.layer(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   List[Any]       				=  self.shortcut(SCREAMING_SNAKE_CASE						)
      hidden_state += residual
      UpperCamelCase__			:   Optional[int]       				=  self.activation(SCREAMING_SNAKE_CASE						)
      return hidden_state







class 			__a  (    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							,   ):


      '''simple docstring'''






      super().__init__()

      UpperCamelCase__			:   Tuple       				=  ResNetBottleNeckLayer if config.layer_type == "bottleneck" else ResNetBasicLayer

      UpperCamelCase__			:   List[Any]       				=  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 					__lowercase					(		self					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   Tensor						):


      '''simple docstring'''






      UpperCamelCase__			:   str       				=  input
      for layer in self.layers:
           UpperCamelCase__			:   Any       				=  layer(SCREAMING_SNAKE_CASE						)
      return hidden_state







class 			__a  (    nn.Module       ):







 def __init__(		self					:   List[str]							,   SCREAMING_SNAKE_CASE					:   ResNetConfig						):


      '''simple docstring'''






      super().__init__()
      UpperCamelCase__			:   List[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]							,   )						)
      UpperCamelCase__			:   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 					__lowercase					(		self					:   Union[str, Any]							,   SCREAMING_SNAKE_CASE					:   Tensor							,   SCREAMING_SNAKE_CASE					:   bool = False							,   SCREAMING_SNAKE_CASE					:   bool = True						):


      '''simple docstring'''






      UpperCamelCase__			:   List[str]       				=  () if output_hidden_states else None

      for stage_module in self.stages:
           if output_hidden_states:
                UpperCamelCase__			:   Union[str, Any]       				=  hidden_states + (hidden_state,)

           UpperCamelCase__			:   int       				=  stage_module(SCREAMING_SNAKE_CASE						)

      if output_hidden_states:
           UpperCamelCase__			:   List[str]       				=  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 			__a  (    A__       ):
 _lowerCAmelCase       :       List[str]        = ResNetConfig
 _lowerCAmelCase       :       Optional[Any]        = '''resnet'''
 _lowerCAmelCase       :       Tuple        = '''pixel_values'''
 _lowerCAmelCase       :       List[str]        = True







 def 					__lowercase					(		self					:   int							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]						):


      '''simple docstring'''






      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 					__lowercase					(		self					:   Any							,   SCREAMING_SNAKE_CASE					:   Union[str, Any]							,   SCREAMING_SNAKE_CASE					:   int=False						):


      '''simple docstring'''






      if isinstance(SCREAMING_SNAKE_CASE							,   SCREAMING_SNAKE_CASE						):
           UpperCamelCase__			:   Tuple       				=  value







lowerCamelCase	:							Any				=R'''
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it
    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.

    Parameters:
        config ([`ResNetConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
'''

lowerCamelCase	:							Optional[int]				=R'''
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See
            [`ConvNextImageProcessor.__call__`] for details.

        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
            more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
'''





@add_start_docstrings(
    '''The bare ResNet model outputting raw features without any specific head on top.'''       ,   A__       ,   )
class 			__a  (    A__       ):







 def __init__(		self					:   Optional[Any]							,   SCREAMING_SNAKE_CASE					:   str						):


      '''simple docstring'''






      super().__init__(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   str       				=  config
      UpperCamelCase__			:   List[Any]       				=  ResNetEmbeddings(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Optional[Any]       				=  ResNetEncoder(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Dict       				=  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 					__lowercase					(		self					:   List[Any]							,   SCREAMING_SNAKE_CASE					:   Tensor							,   SCREAMING_SNAKE_CASE					:   Optional[bool] = None							,   SCREAMING_SNAKE_CASE					:   Optional[bool] = None						):


      '''simple docstring'''






      UpperCamelCase__			:   Union[str, Any]       				=  (
          output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
      )
      UpperCamelCase__			:   int       				=  return_dict if return_dict is not None else self.config.use_return_dict

      UpperCamelCase__			:   Tuple       				=  self.embedder(SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   Dict       				=  self.encoder(
          SCREAMING_SNAKE_CASE							,   output_hidden_states=SCREAMING_SNAKE_CASE							,   return_dict=SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   Dict       				=  encoder_outputs[0]

      UpperCamelCase__			:   Optional[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(
    '''
    ResNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for
    ImageNet.
    '''       ,   A__       ,   )
class 			__a  (    A__       ):







 def __init__(		self					:   Optional[int]							,   SCREAMING_SNAKE_CASE					:   str						):


      '''simple docstring'''






      super().__init__(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   Union[str, Any]       				=  config.num_labels
      UpperCamelCase__			:   Any       				=  ResNetModel(SCREAMING_SNAKE_CASE						)
      # classification head
      UpperCamelCase__			:   str       				=  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 					__lowercase					(		self					:   int							,   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							,   ):


      '''simple docstring'''






      UpperCamelCase__			:   Union[str, Any]       				=  return_dict if return_dict is not None else self.config.use_return_dict

      UpperCamelCase__			:   Tuple       				=  self.resnet(SCREAMING_SNAKE_CASE							,   output_hidden_states=SCREAMING_SNAKE_CASE							,   return_dict=SCREAMING_SNAKE_CASE						)

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

      UpperCamelCase__			:   str       				=  self.classifier(SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   Optional[Any]       				=  None

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

      if not return_dict:
           UpperCamelCase__			:   Dict       				=  (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(
    '''
    ResNet backbone, to be used with frameworks like DETR and MaskFormer.
    '''       ,   A__       ,   )
class 			__a  (    A__       ,   A__       ):







 def __init__(		self					:   List[str]							,   SCREAMING_SNAKE_CASE					:   List[Any]						):


      '''simple docstring'''






      super().__init__(SCREAMING_SNAKE_CASE						)
      super()._init_backbone(SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   Union[str, Any]       				=  [config.embedding_size] + config.hidden_sizes
      UpperCamelCase__			:   str       				=  ResNetEmbeddings(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__			:   List[str]       				=  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 					__lowercase					(		self					:   Optional[Any]							,   SCREAMING_SNAKE_CASE					:   Tensor							,   SCREAMING_SNAKE_CASE					:   Optional[bool] = None							,   SCREAMING_SNAKE_CASE					:   Optional[bool] = None						):


      '''simple docstring'''






      UpperCamelCase__			:   Optional[Any]       				=  return_dict if return_dict is not None else self.config.use_return_dict
      UpperCamelCase__			:   Tuple       				=  (
          output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
      )

      UpperCamelCase__			:   int       				=  self.embedder(SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   Union[str, Any]       				=  self.encoder(SCREAMING_SNAKE_CASE							,   output_hidden_states=SCREAMING_SNAKE_CASE							,   return_dict=SCREAMING_SNAKE_CASE						)

      UpperCamelCase__			:   List[str]       				=  outputs.hidden_states

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

      if not return_dict:
           UpperCamelCase__			:   List[str]       				=  (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							,   )







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available


lowerCamelCase	:							int				={
    '''configuration_audio_spectrogram_transformer''': [
        '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''ASTConfig''',
    ]
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase	:							Union[str, Any]				=[
     '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''ASTForAudioClassification''',
     '''ASTModel''',
     '''ASTPreTrainedModel''',
 ]

try:
 if not is_speech_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase	:							Optional[int]				=['''ASTFeatureExtractor''']

if TYPE_CHECKING:
 from .configuration_audio_spectrogram_transformer import (
     AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
     ASTConfig,
 )

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_audio_spectrogram_transformer import (
      AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
      ASTForAudioClassification,
      ASTModel,
      ASTPreTrainedModel,
  )

 try:
  if not is_speech_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .feature_extraction_audio_spectrogram_transformer import ASTFeatureExtractor


else:
 import sys

 lowerCamelCase	:							Optional[int]				=_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)