




from typing import Optional, Union

import torch
from torch import nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention
from ...modeling_utils import PreTrainedModel
from ...utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, logging
from .configuration_mobilenet_va import MobileNetVaConfig


__a          =			logging.get_logger(__name__)


# General docstring
__a          =			'MobileNetV1Config'

# Base docstring
__a          =			'google/mobilenet_v1_1.0_224'
__a          =			[1, 1_024, 7, 7]

# Image classification docstring
__a          =			'google/mobilenet_v1_1.0_224'
__a          =			'tabby, tabby cat'


__a          =			[
    'google/mobilenet_v1_1.0_224',
    'google/mobilenet_v1_0.75_192',
    # See all MobileNetV1 models at https://huggingface.co/models?filter=mobilenet_v1
]







def lowerCamelCase__       (      _lowercase			,						_lowercase			,						_lowercase=None				):

     '''simple docstring'''


     UpperCAmelCase_      :							str       =      {}

     if isinstance(_lowercase			,						_lowercase				):
          UpperCAmelCase_      :							List[Any]       =      model.mobilenet_va
     else:
          UpperCAmelCase_      :							Union[str, Any]       =      model

     UpperCAmelCase_      :							Any       =      '''MobilenetV1/Conv2d_0/'''
     UpperCAmelCase_      :							str       =      backbone.conv_stem.convolution.weight
     UpperCAmelCase_      :							Any       =      backbone.conv_stem.normalization.bias
     UpperCAmelCase_      :							List[str]       =      backbone.conv_stem.normalization.weight
     UpperCAmelCase_      :							int       =      backbone.conv_stem.normalization.running_mean
     UpperCAmelCase_      :							Optional[int]       =      backbone.conv_stem.normalization.running_var

     for i in range(13				):
          UpperCAmelCase_      :							Dict       =      i + 1
          UpperCAmelCase_      :							Union[str, Any]       =      i * 2

          UpperCAmelCase_      :							str       =      backbone.layer[pt_index]
          UpperCAmelCase_      :							Optional[Any]       =      f'''MobilenetV1/Conv2d_{tf_index}_depthwise/'''
          UpperCAmelCase_      :							List[str]       =      pointer.convolution.weight
          UpperCAmelCase_      :							List[str]       =      pointer.normalization.bias
          UpperCAmelCase_      :							str       =      pointer.normalization.weight
          UpperCAmelCase_      :							str       =      pointer.normalization.running_mean
          UpperCAmelCase_      :							Union[str, Any]       =      pointer.normalization.running_var

          UpperCAmelCase_      :							Optional[int]       =      backbone.layer[pt_index + 1]
          UpperCAmelCase_      :							Tuple       =      f'''MobilenetV1/Conv2d_{tf_index}_pointwise/'''
          UpperCAmelCase_      :							Dict       =      pointer.convolution.weight
          UpperCAmelCase_      :							Union[str, Any]       =      pointer.normalization.bias
          UpperCAmelCase_      :							str       =      pointer.normalization.weight
          UpperCAmelCase_      :							List[Any]       =      pointer.normalization.running_mean
          UpperCAmelCase_      :							Union[str, Any]       =      pointer.normalization.running_var

     if isinstance(_lowercase			,						_lowercase				):
          UpperCAmelCase_      :							Dict       =      '''MobilenetV1/Logits/Conv2d_1c_1x1/'''
          UpperCAmelCase_      :							Optional[int]       =      model.classifier.weight
          UpperCAmelCase_      :							int       =      model.classifier.bias

     return tf_to_pt_map







def lowerCamelCase__       (      _lowercase			,						_lowercase			,						_lowercase				):

     '''simple docstring'''


     try:
          import numpy as np
          import tensorflow as tf
     except ImportError:
          logger.error(
              '''Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please see '''
              '''https://www.tensorflow.org/install/ for installation instructions.'''				)
          raise

     # Load weights from TF model
     UpperCAmelCase_      :							List[str]       =      tf.train.list_variables(_lowercase				)
     UpperCAmelCase_      :							Optional[Any]       =      {}
     for name, shape in init_vars:
          logger.info(f'''Loading TF weight {name} with shape {shape}'''				)
          UpperCAmelCase_      :							Any       =      tf.train.load_variable(_lowercase			,						_lowercase				)
          UpperCAmelCase_      :							Tuple       =      array

     # Build TF to PyTorch weights loading map
     UpperCAmelCase_      :							Dict       =      _build_tf_to_pytorch_map(_lowercase			,						_lowercase			,						_lowercase				)

     for name, pointer in tf_to_pt_map.items():
          logger.info(f'''Importing {name}'''				)
          if name not in tf_weights:
               logger.info(f'''{name} not in tf pre-trained weights, skipping'''				)
               continue

          UpperCAmelCase_      :							Optional[Any]       =      tf_weights[name]

          if "depthwise_weights" in name:
               logger.info('''Transposing depthwise'''				)
               UpperCAmelCase_      :							List[str]       =      np.transpose(_lowercase			,						(2, 3, 0, 1)				)
          elif "weights" in name:
               logger.info('''Transposing'''				)
               if len(pointer.shape				) == 2:  # copying into linear layer
                    UpperCAmelCase_      :							str       =      array.squeeze().transpose()
               else:
                    UpperCAmelCase_      :							Dict       =      np.transpose(_lowercase			,						(3, 2, 0, 1)				)

          if pointer.shape != array.shape:
               raise ValueError(f'''Pointer shape {pointer.shape} and array shape {array.shape} mismatched'''				)

          logger.info(f'''Initialize PyTorch weight {name} {array.shape}'''				)
          UpperCAmelCase_      :							Any       =      torch.from_numpy(_lowercase				)

          tf_weights.pop(_lowercase			,						_lowercase				)
          tf_weights.pop(name + '''/RMSProp'''			,						_lowercase				)
          tf_weights.pop(name + '''/RMSProp_1'''			,						_lowercase				)
          tf_weights.pop(name + '''/ExponentialMovingAverage'''			,						_lowercase				)

     logger.info(f'''Weights not copied to PyTorch model: {", ".join(tf_weights.keys()				)}'''				)
     return model







def lowerCamelCase__       (      _lowercase			,						_lowercase				):

     '''simple docstring'''


     UpperCAmelCase_,   UpperCAmelCase_      :							str       =      features.shape[-2:]
     UpperCAmelCase_,   UpperCAmelCase_      :							Union[str, Any]       =      conv_layer.stride
     UpperCAmelCase_,   UpperCAmelCase_      :							Dict       =      conv_layer.kernel_size

     if in_height % stride_height == 0:
          UpperCAmelCase_      :							str       =      max(kernel_height - stride_height			,						0				)
     else:
          UpperCAmelCase_      :							Any       =      max(kernel_height - (in_height % stride_height)			,						0				)

     if in_width % stride_width == 0:
          UpperCAmelCase_      :							Optional[int]       =      max(kernel_width - stride_width			,						0				)
     else:
          UpperCAmelCase_      :							str       =      max(kernel_width - (in_width % stride_width)			,						0				)

     UpperCAmelCase_      :							Dict       =      pad_along_width // 2
     UpperCAmelCase_      :							Optional[Any]       =      pad_along_width - pad_left
     UpperCAmelCase_      :							List[str]       =      pad_along_height // 2
     UpperCAmelCase_      :							Optional[Any]       =      pad_along_height - pad_top

     UpperCAmelCase_      :							int       =      (pad_left, pad_right, pad_top, pad_bottom)
     return nn.functional.pad(_lowercase			,						_lowercase			,						'''constant'''			,						0.0				)

class   __a(					nn.Module       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE = 1       ,_SCREAMING_SNAKE_CASE = 1       ,_SCREAMING_SNAKE_CASE = False       ,_SCREAMING_SNAKE_CASE = True       ,_SCREAMING_SNAKE_CASE = True       ,)			->		None:
         super().__init__()
         UpperCAmelCase_      :							Optional[Any]       =      config

         if in_channels % groups != 0:
              raise ValueError(f'''Input channels ({in_channels}) are not divisible by {groups} groups.'''  )
         if out_channels % groups != 0:
              raise ValueError(f'''Output channels ({out_channels}) are not divisible by {groups} groups.'''  )

         UpperCAmelCase_      :							Optional[int]       =      0 if config.tf_padding else int((kernel_size - 1) / 2  )

         UpperCAmelCase_      :							Dict       =      nn.Convad(
             in_channels=_SCREAMING_SNAKE_CASE       ,out_channels=_SCREAMING_SNAKE_CASE       ,kernel_size=_SCREAMING_SNAKE_CASE       ,stride=_SCREAMING_SNAKE_CASE       ,padding=_SCREAMING_SNAKE_CASE       ,groups=_SCREAMING_SNAKE_CASE       ,bias=_SCREAMING_SNAKE_CASE       ,padding_mode='''zeros'''       ,)

         if use_normalization:
              UpperCAmelCase_      :							Union[str, Any]       =      nn.BatchNormad(
                  num_features=_SCREAMING_SNAKE_CASE       ,eps=config.layer_norm_eps       ,momentum=0.99_97       ,affine=_SCREAMING_SNAKE_CASE       ,track_running_stats=_SCREAMING_SNAKE_CASE       ,)
         else:
              UpperCAmelCase_      :							List[Any]       =      None

         if use_activation:
              if isinstance(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  ):
                   UpperCAmelCase_      :							List[str]       =      ACTaFN[use_activation]
              elif isinstance(config.hidden_act       ,_SCREAMING_SNAKE_CASE  ):
                   UpperCAmelCase_      :							Optional[Any]       =      ACTaFN[config.hidden_act]
              else:
                   UpperCAmelCase_      :							List[str]       =      config.hidden_act
         else:
              UpperCAmelCase_      :							List[Any]       =      None





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		torch.Tensor:
         if self.config.tf_padding:
              UpperCAmelCase_      :							List[Any]       =      apply_tf_padding(_SCREAMING_SNAKE_CASE       ,self.convolution  )
         UpperCAmelCase_      :							str       =      self.convolution(_SCREAMING_SNAKE_CASE  )
         if self.normalization is not None:
              UpperCAmelCase_      :							Any       =      self.normalization(_SCREAMING_SNAKE_CASE  )
         if self.activation is not None:
              UpperCAmelCase_      :							List[str]       =      self.activation(_SCREAMING_SNAKE_CASE  )
         return features


class   __a(					_a       ):






    """simple docstring"""





    lowerCAmelCase        =				MobileNetVaConfig
    lowerCAmelCase        =				load_tf_weights_in_mobilenet_va
    lowerCAmelCase        =				'''mobilenet_v1'''
    lowerCAmelCase        =				'''pixel_values'''
    lowerCAmelCase        =				False





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		None:
         if isinstance(_SCREAMING_SNAKE_CASE       ,(nn.Linear, nn.Convad)  ):
              module.weight.data.normal_(mean=0.0       ,std=self.config.initializer_range  )
              if module.bias is not None:
                   module.bias.data.zero_()
         elif isinstance(_SCREAMING_SNAKE_CASE       ,nn.BatchNormad  ):
              module.bias.data.zero_()
              module.weight.data.fill_(1.0  )


__a          =			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 ([`MobileNetV1Config`]): 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'

__a          =			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            [`MobileNetV1ImageProcessor.__call__`] for details.\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 MobileNetV1 model outputting raw hidden-states without any specific head on top.'''    ,						_a    ,						)
class   __a(					_a       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE = True  )			->		Any:
         super().__init__(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Any       =      config

         UpperCAmelCase_      :							List[str]       =      32
         UpperCAmelCase_      :							List[Any]       =      max(int(depth * config.depth_multiplier  )       ,config.min_depth  )

         UpperCAmelCase_      :							List[str]       =      MobileNetVaConvLayer(
             _SCREAMING_SNAKE_CASE       ,in_channels=config.num_channels       ,out_channels=_SCREAMING_SNAKE_CASE       ,kernel_size=3       ,stride=2       ,)

         UpperCAmelCase_      :							Any       =      [1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1]

         UpperCAmelCase_      :							str       =      nn.ModuleList()
         for i in range(13  ):
              UpperCAmelCase_      :							Any       =      out_channels

              if strides[i] == 2 or i == 0:
                   depth *= 2
                   UpperCAmelCase_      :							Dict       =      max(int(depth * config.depth_multiplier  )       ,config.min_depth  )

              self.layer.append(
                  MobileNetVaConvLayer(
                      _SCREAMING_SNAKE_CASE       ,in_channels=_SCREAMING_SNAKE_CASE       ,out_channels=_SCREAMING_SNAKE_CASE       ,kernel_size=3       ,stride=strides[i]       ,groups=_SCREAMING_SNAKE_CASE       ,)  )

              self.layer.append(
                  MobileNetVaConvLayer(
                      _SCREAMING_SNAKE_CASE       ,in_channels=_SCREAMING_SNAKE_CASE       ,out_channels=_SCREAMING_SNAKE_CASE       ,kernel_size=1       ,)  )

         UpperCAmelCase_      :							Optional[int]       =      nn.AdaptiveAvgPoolad((1, 1)  ) if add_pooling_layer else None

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





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		str:
         raise NotImplementedError





    @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 							a__				(				self       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,)			->		Union[tuple, BaseModelOutputWithPoolingAndNoAttention]:
         UpperCAmelCase_      :							Optional[Any]       =      (
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         UpperCAmelCase_      :							List[Any]       =      return_dict if return_dict is not None else self.config.use_return_dict

         if pixel_values is None:
              raise ValueError('''You have to specify pixel_values'''  )

         UpperCAmelCase_      :							str       =      self.conv_stem(_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							int       =      () if output_hidden_states else None

         for i, layer_module in enumerate(self.layer  ):
              UpperCAmelCase_      :							Dict       =      layer_module(_SCREAMING_SNAKE_CASE  )

              if output_hidden_states:
                   UpperCAmelCase_      :							Optional[Any]       =      all_hidden_states + (hidden_states,)

         UpperCAmelCase_      :							Optional[Any]       =      hidden_states

         if self.pooler is not None:
              UpperCAmelCase_      :							int       =      torch.flatten(self.pooler(_SCREAMING_SNAKE_CASE  )       ,start_dim=1  )
         else:
              UpperCAmelCase_      :							Any       =      None

         if not return_dict:
              return tuple(v for v in [last_hidden_state, pooled_output, all_hidden_states] if v is not None  )

         return BaseModelOutputWithPoolingAndNoAttention(
             last_hidden_state=_SCREAMING_SNAKE_CASE       ,pooler_output=_SCREAMING_SNAKE_CASE       ,hidden_states=_SCREAMING_SNAKE_CASE       ,)


@add_start_docstrings(
    '''
    MobileNetV1 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       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE  )			->		None:
         super().__init__(_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							str       =      config.num_labels
         UpperCAmelCase_      :							str       =      MobileNetVaModel(_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							List[str]       =      self.mobilenet_va.layer[-1].convolution.out_channels

         # Classifier head
         UpperCAmelCase_      :							List[str]       =      nn.Dropout(config.classifier_dropout_prob       ,inplace=_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							List[Any]       =      nn.Linear(_SCREAMING_SNAKE_CASE       ,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 							a__				(				self       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,)			->		Union[tuple, ImageClassifierOutputWithNoAttention]:
         UpperCAmelCase_      :							Union[str, Any]       =      return_dict if return_dict is not None else self.config.use_return_dict

         UpperCAmelCase_      :							str       =      self.mobilenet_va(_SCREAMING_SNAKE_CASE       ,output_hidden_states=_SCREAMING_SNAKE_CASE       ,return_dict=_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							Tuple       =      outputs.pooler_output if return_dict else outputs[1]

         UpperCAmelCase_      :							Dict       =      self.classifier(self.dropout(_SCREAMING_SNAKE_CASE  )  )

         UpperCAmelCase_      :							List[Any]       =      None
         if labels is not None:
              if self.config.problem_type is None:
                   if self.num_labels == 1:
                        UpperCAmelCase_      :							Optional[Any]       =      '''regression'''
                   elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
                        UpperCAmelCase_      :							Dict       =      '''single_label_classification'''
                   else:
                        UpperCAmelCase_      :							Optional[int]       =      '''multi_label_classification'''

              if self.config.problem_type == "regression":
                   UpperCAmelCase_      :							Union[str, Any]       =      MSELoss()
                   if self.num_labels == 1:
                        UpperCAmelCase_      :							Optional[Any]       =      loss_fct(logits.squeeze()       ,labels.squeeze()  )
                   else:
                        UpperCAmelCase_      :							Union[str, Any]       =      loss_fct(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )
              elif self.config.problem_type == "single_label_classification":
                   UpperCAmelCase_      :							str       =      CrossEntropyLoss()
                   UpperCAmelCase_      :							Tuple       =      loss_fct(logits.view(-1       ,self.num_labels  )       ,labels.view(-1  )  )
              elif self.config.problem_type == "multi_label_classification":
                   UpperCAmelCase_      :							str       =      BCEWithLogitsLoss()
                   UpperCAmelCase_      :							Tuple       =      loss_fct(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )

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





from ...processing_utils import ProcessorMixin

class   __a(					_a       ):






    """simple docstring"""





    lowerCAmelCase        =				'''SpeechT5FeatureExtractor'''
    lowerCAmelCase        =				'''SpeechT5Tokenizer'''





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )			->		int:
         super().__init__(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )





    def __call__(				self       ,*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )			->		int:
         UpperCAmelCase_      :							List[str]       =      kwargs.pop('''audio'''       ,_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							str       =      kwargs.pop('''text'''       ,_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							List[str]       =      kwargs.pop('''text_target'''       ,_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							int       =      kwargs.pop('''audio_target'''       ,_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Tuple       =      kwargs.pop('''sampling_rate'''       ,_SCREAMING_SNAKE_CASE  )

         if audio is not None and text is not None:
              raise ValueError(
                  '''Cannot process both `audio` and `text` inputs. Did you mean `audio_target` or `text_target`?'''  )
         if audio_target is not None and text_target is not None:
              raise ValueError(
                  '''Cannot process both `audio_target` and `text_target` inputs. Did you mean `audio` or `text`?'''  )
         if audio is None and audio_target is None and text is None and text_target is None:
              raise ValueError(
                  '''You need to specify either an `audio`, `audio_target`, `text`, or `text_target` input to process.'''  )

         if audio is not None:
              UpperCAmelCase_      :							Optional[Any]       =      self.feature_extractor(_SCREAMING_SNAKE_CASE       ,*_SCREAMING_SNAKE_CASE       ,sampling_rate=_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
         elif text is not None:
              UpperCAmelCase_      :							Dict       =      self.tokenizer(_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
         else:
              UpperCAmelCase_      :							List[str]       =      None

         if audio_target is not None:
              UpperCAmelCase_      :							List[Any]       =      self.feature_extractor(audio_target=_SCREAMING_SNAKE_CASE       ,*_SCREAMING_SNAKE_CASE       ,sampling_rate=_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
              UpperCAmelCase_      :							int       =      targets['''input_values''']
         elif text_target is not None:
              UpperCAmelCase_      :							Optional[int]       =      self.tokenizer(_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
              UpperCAmelCase_      :							Optional[Any]       =      targets['''input_ids''']
         else:
              UpperCAmelCase_      :							Tuple       =      None

         if inputs is None:
              return targets

         if targets is not None:
              UpperCAmelCase_      :							Dict       =      labels

              UpperCAmelCase_      :							Optional[int]       =      targets.get('''attention_mask'''  )
              if decoder_attention_mask is not None:
                   UpperCAmelCase_      :							List[Any]       =      decoder_attention_mask

         return inputs





    def 							a__				(				self       ,*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )			->		Tuple:
         UpperCAmelCase_      :							Dict       =      kwargs.pop('''input_values'''       ,_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Union[str, Any]       =      kwargs.pop('''input_ids'''       ,_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							List[str]       =      kwargs.pop('''labels'''       ,_SCREAMING_SNAKE_CASE  )

         if input_values is not None and input_ids is not None:
              raise ValueError('''Cannot process both `input_values` and `input_ids` inputs.'''  )
         if input_values is None and input_ids is None and labels is None:
              raise ValueError(
                  '''You need to specify either an `input_values`, `input_ids`, or `labels` input to be padded.'''  )

         if input_values is not None:
              UpperCAmelCase_      :							Tuple       =      self.feature_extractor.pad(_SCREAMING_SNAKE_CASE       ,*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
         elif input_ids is not None:
              UpperCAmelCase_      :							Tuple       =      self.tokenizer.pad(_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
         else:
              UpperCAmelCase_      :							List[str]       =      None

         if labels is not None:
              if "input_ids" in labels or (isinstance(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  ) and "input_ids" in labels[0]):
                   UpperCAmelCase_      :							Tuple       =      self.tokenizer.pad(_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
                   UpperCAmelCase_      :							Any       =      targets['''input_ids''']
              else:
                   UpperCAmelCase_      :							int       =      self.feature_extractor.feature_size
                   UpperCAmelCase_      :							List[str]       =      self.feature_extractor.num_mel_bins
                   UpperCAmelCase_      :							Optional[Any]       =      self.feature_extractor.pad(_SCREAMING_SNAKE_CASE       ,*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )
                   UpperCAmelCase_      :							List[Any]       =      feature_size_hack
                   UpperCAmelCase_      :							List[Any]       =      targets['''input_values''']
         else:
              UpperCAmelCase_      :							Optional[int]       =      None

         if inputs is None:
              return targets

         if targets is not None:
              UpperCAmelCase_      :							Optional[int]       =      labels

              UpperCAmelCase_      :							Union[str, Any]       =      targets.get('''attention_mask'''  )
              if decoder_attention_mask is not None:
                   UpperCAmelCase_      :							List[Any]       =      decoder_attention_mask

         return inputs





    def 							a__				(				self       ,*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )			->		Optional[Any]:
         return self.tokenizer.batch_decode(*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )





    def 							a__				(				self       ,*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )			->		Union[str, Any]:
         return self.tokenizer.decode(*_SCREAMING_SNAKE_CASE       ,**_SCREAMING_SNAKE_CASE  )