

'''simple docstring'''

from typing import List, Optional, Union

import numpy as np

from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
from ...feature_extraction_utils import BatchFeature
from ...utils import PaddingStrategy, TensorType, logging


a       :      Optional[Any]  	=			logging.get_logger(__name__)







class   UpperCamelCase__   (       __UpperCAmelCase       ):


		"""simple docstring"""

		SCREAMING_SNAKE_CASE__  :     List[Any]       =							["""input_values""", """attention_mask"""]







		def __init__(			self   ,      snake_case=1   ,      snake_case=1_6_0_0_0   ,      snake_case=0.0   ,      snake_case=False   ,      snake_case=True   ,      **snake_case   ,      ):


							'''simple docstring'''

							super().__init__(feature_size=lowerCamelCase__   ,      sampling_rate=lowerCamelCase__   ,      padding_value=lowerCamelCase__   ,      **lowerCamelCase__      )
							UpperCAmelCase		:							Optional[int]        =       return_attention_mask
							UpperCAmelCase		:							int        =       do_normalize







		@staticmethod
		def 				A_	(			snake_case   ,      snake_case   ,      snake_case = 0.0      ):


							'''simple docstring'''

							if attention_mask is not None:
												UpperCAmelCase		:							Union[str, Any]        =       np.array(lowerCamelCase__   ,      np.intaa      )
												UpperCAmelCase		:							Optional[int]        =       []

												for vector, length in zip(lowerCamelCase__   ,      attention_mask.sum(-1      )      ):
																	UpperCAmelCase		:							Tuple        =       (vector - vector[:length].mean()) / np.sqrt(vector[:length].var() + 1e-7      )
																	if length < normed_slice.shape[0]:
																						UpperCAmelCase		:							str        =       padding_value

																	normed_input_values.append(lowerCamelCase__      )
							else:
												UpperCAmelCase		:							Optional[int]        =       [(x - x.mean()) / np.sqrt(x.var() + 1e-7      ) for x in input_values]

							return normed_input_values







		def __call__(			self   ,      snake_case   ,      snake_case = False   ,      snake_case = None   ,      snake_case = False   ,      snake_case = None   ,      snake_case = None   ,      snake_case = None   ,      snake_case = None   ,      **snake_case   ,      ):


							'''simple docstring'''

							if sampling_rate is not None:
												if sampling_rate != self.sampling_rate:
																	raise ValueError(
																	    f"The model corresponding to this feature extractor: {self} was trained using a sampling rate of"
																	    f" {self.sampling_rate}. Please make sure that the provided `raw_speech` input was sampled with"
																	    f" {self.sampling_rate} and not {sampling_rate}."      )
							else:
												logger.warning(
												    "It is strongly recommended to pass the ``sampling_rate`` argument to this function. "
												    "Failing to do so can result in silent errors that might be hard to debug."      )

							UpperCAmelCase		:							List[Any]        =       isinstance(lowerCamelCase__   ,      np.ndarray      ) and len(raw_speech.shape      ) > 1
							if is_batched_numpy and len(raw_speech.shape      ) > 2:
												raise ValueError(f"Only mono-channel audio is supported for input to {self}"      )
							UpperCAmelCase		:							Any        =       is_batched_numpy or (
							    isinstance(lowerCamelCase__   ,      (list, tuple)      ) and (isinstance(raw_speech[0]   ,      (np.ndarray, tuple, list)      ))
							)

							# always return batch
							if not is_batched:
												UpperCAmelCase		:							Optional[Any]        =       [raw_speech]

							# convert into correct format for padding
							UpperCAmelCase		:							List[str]        =       BatchFeature({"input_values": raw_speech}      )

							UpperCAmelCase		:							Any        =       self.pad(
							    lowerCamelCase__   ,      padding=lowerCamelCase__   ,      max_length=lowerCamelCase__   ,      truncation=lowerCamelCase__   ,      pad_to_multiple_of=lowerCamelCase__   ,      return_attention_mask=lowerCamelCase__   ,      )

							# convert input values to correct format
							UpperCAmelCase		:							Union[str, Any]        =       padded_inputs["input_values"]
							if not isinstance(input_values[0]   ,      np.ndarray      ):
												UpperCAmelCase		:							Tuple        =       [np.asarray(lowerCamelCase__   ,      dtype=np.floataa      ) for array in input_values]
							elif (
							    not isinstance(lowerCamelCase__   ,      np.ndarray      )
							    and isinstance(input_values[0]   ,      np.ndarray      )
							    and input_values[0].dtype is np.dtype(np.floataa      )
							):
												UpperCAmelCase		:							Tuple        =       [array.astype(np.floataa      ) for array in input_values]
							elif isinstance(lowerCamelCase__   ,      np.ndarray      ) and input_values.dtype is np.dtype(np.floataa      ):
												UpperCAmelCase		:							Union[str, Any]        =       input_values.astype(np.floataa      )

							# convert attention_mask to correct format
							UpperCAmelCase		:							List[Any]        =       padded_inputs.get("attention_mask"      )
							if attention_mask is not None:
												UpperCAmelCase		:							str        =       [np.asarray(lowerCamelCase__   ,      dtype=np.intaa      ) for array in attention_mask]

							# zero-mean and unit-variance normalization
							if self.do_normalize:
												UpperCAmelCase		:							List[str]        =       (
												    attention_mask
												    if self._get_padding_strategies(lowerCamelCase__   ,      max_length=lowerCamelCase__      ) is not PaddingStrategy.DO_NOT_PAD
												    else None
												)
												UpperCAmelCase		:							List[str]        =       self.zero_mean_unit_var_norm(
												    padded_inputs["input_values"]   ,      attention_mask=lowerCamelCase__   ,      padding_value=self.padding_value      )

							if return_tensors is not None:
												UpperCAmelCase		:							Dict        =       padded_inputs.convert_to_tensors(lowerCamelCase__      )

							return padded_inputs



'''simple docstring'''

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


a       :      List[Any]  	=			logging.get_logger(__name__)

a       :      Dict  	=			{
    "apple/mobilevitv2-1.0": "https://huggingface.co/apple/mobilevitv2-1.0/resolve/main/config.json",
}







class   UpperCamelCase__   (       lowercase__       ):


		"""simple docstring"""

		SCREAMING_SNAKE_CASE__  :     List[Any]       =							"mobilevitv2"







		def __init__(			self   ,      snake_case=3   ,      snake_case=2_5_6   ,      snake_case=2   ,      snake_case=2.0   ,      snake_case="swish"   ,      snake_case=3   ,      snake_case=3_2   ,      snake_case=0.1   ,      snake_case=0.02   ,      snake_case=1e-5   ,      snake_case=5_1_2   ,      snake_case=[6, 1_2, 1_8]   ,      snake_case=0.1   ,      snake_case=2_5_5   ,      snake_case=[2, 4, 3]   ,      snake_case=[1_2_8, 1_9_2, 2_5_6]   ,      snake_case=1.0   ,      snake_case=2   ,      snake_case=0.0   ,      snake_case=0.0   ,      **snake_case   ,      ):


							'''simple docstring'''

							super().__init__(**snake_case      )

							UpperCAmelCase		:							Tuple        =       num_channels
							UpperCAmelCase		:							Optional[int]        =       image_size
							UpperCAmelCase		:							Optional[int]        =       patch_size
							UpperCAmelCase		:							Optional[int]        =       expand_ratio
							UpperCAmelCase		:							List[Any]        =       hidden_act
							UpperCAmelCase		:							Optional[Any]        =       conv_kernel_size
							UpperCAmelCase		:							str        =       output_stride
							UpperCAmelCase		:							Optional[Any]        =       initializer_range
							UpperCAmelCase		:							Optional[Any]        =       layer_norm_eps
							UpperCAmelCase		:							List[str]        =       n_attn_blocks
							UpperCAmelCase		:							Any        =       base_attn_unit_dims
							UpperCAmelCase		:							str        =       width_multiplier
							UpperCAmelCase		:							Optional[int]        =       ffn_multiplier
							UpperCAmelCase		:							List[Any]        =       ffn_dropout
							UpperCAmelCase		:							List[str]        =       attn_dropout
							UpperCAmelCase		:							Optional[Any]        =       classifier_dropout_prob

							# decode head attributes for semantic segmentation
							UpperCAmelCase		:							Optional[Any]        =       aspp_out_channels
							UpperCAmelCase		:							Dict        =       atrous_rates
							UpperCAmelCase		:							int        =       aspp_dropout_prob
							UpperCAmelCase		:							List[str]        =       semantic_loss_ignore_index







class   UpperCamelCase__   (       lowercase__       ):


		"""simple docstring"""

		SCREAMING_SNAKE_CASE__  :     Optional[int]       =							version.parse("1.11"       )







		@property
		def 				A_	(			self      ):


							'''simple docstring'''

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







		@property
		def 				A_	(			self      ):


							'''simple docstring'''

							if self.task == "image-classification":
												return OrderedDict([("logits", {0: "batch"})]      )
							else:
												return OrderedDict([("last_hidden_state", {0: "batch"}), ("pooler_output", {0: "batch"})]      )







		@property
		def 				A_	(			self      ):


							'''simple docstring'''

							return 1e-4
