





"""simple docstring"""
import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
		import torch

		from transformers import (
		    RemBertConfig,
		    RemBertForCausalLM,
		    RemBertForMaskedLM,
		    RemBertForMultipleChoice,
		    RemBertForQuestionAnswering,
		    RemBertForSequenceClassification,
		    RemBertForTokenClassification,
		    RemBertModel,
		)
		from transformers.models.rembert.modeling_rembert import REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST






class    _UpperCAmelCase  :


					def __init__(   self     :Union[str, Any]	,			__UpperCamelCase     :List[str]	,			__UpperCamelCase     :Union[str, Any]=13	,			__UpperCamelCase     :Tuple=7	,			__UpperCamelCase     :Union[str, Any]=True	,			__UpperCamelCase     :str=True	,			__UpperCamelCase     :Union[str, Any]=True	,			__UpperCamelCase     :List[Any]=True	,			__UpperCamelCase     :Union[str, Any]=99	,			__UpperCamelCase     :Any=32	,			__UpperCamelCase     :int=18	,			__UpperCamelCase     :List[Any]=43	,			__UpperCamelCase     :List[Any]=5	,			__UpperCamelCase     :int=4	,			__UpperCamelCase     :Any=37	,			__UpperCamelCase     :Any="gelu"	,			__UpperCamelCase     :List[str]=0.1	,			__UpperCamelCase     :Optional[int]=0.1	,			__UpperCamelCase     :Union[str, Any]=5_12	,			__UpperCamelCase     :Union[str, Any]=16	,			__UpperCamelCase     :str=2	,			__UpperCamelCase     :int=0.02	,			__UpperCamelCase     :Optional[int]=3	,			__UpperCamelCase     :List[str]=4	,			__UpperCamelCase     :Union[str, Any]=None	,			):
												A						=    parent
												A						=    batch_size
												A						=    seq_length
												A						=    is_training
												A						=    use_input_mask
												A						=    use_token_type_ids
												A						=    use_labels
												A						=    vocab_size
												A						=    hidden_size
												A						=    input_embedding_size
												A						=    output_embedding_size
												A						=    num_hidden_layers
												A						=    num_attention_heads
												A						=    intermediate_size
												A						=    hidden_act
												A						=    hidden_dropout_prob
												A						=    attention_probs_dropout_prob
												A						=    max_position_embeddings
												A						=    type_vocab_size
												A						=    type_sequence_label_size
												A						=    initializer_range
												A						=    num_labels
												A						=    num_choices
												A						=    scope


					def       lowerCamelCase			(   self     :Union[str, Any]						):
												A						=    ids_tensor([self.batch_size, self.seq_length]	,			self.vocab_size						)

												A						=    None
												if self.use_input_mask:
																			A						=    random_attention_mask([self.batch_size, self.seq_length]						)

												A						=    None
												if self.use_token_type_ids:
																			A						=    ids_tensor([self.batch_size, self.seq_length]	,			self.type_vocab_size						)

												A						=    None
												A						=    None
												A						=    None
												if self.use_labels:
																			A						=    ids_tensor([self.batch_size]	,			self.type_sequence_label_size						)
																			A						=    ids_tensor([self.batch_size, self.seq_length]	,			self.num_labels						)
																			A						=    ids_tensor([self.batch_size]	,			self.num_choices						)

												A						=    RemBertConfig(
												    vocab_size=self.vocab_size	,			hidden_size=self.hidden_size	,			input_embedding_size=self.input_embedding_size	,			output_embedding_size=self.output_embedding_size	,			num_hidden_layers=self.num_hidden_layers	,			num_attention_heads=self.num_attention_heads	,			intermediate_size=self.intermediate_size	,			hidden_act=self.hidden_act	,			hidden_dropout_prob=self.hidden_dropout_prob	,			attention_probs_dropout_prob=self.attention_probs_dropout_prob	,			max_position_embeddings=self.max_position_embeddings	,			type_vocab_size=self.type_vocab_size	,			is_decoder=__UpperCamelCase	,			initializer_range=self.initializer_range	,			)

												return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


					def       lowerCamelCase			(   self     :List[str]						):
												(
												    (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      
												)						=    self.prepare_config_and_inputs()

												A						=    True
												A						=    floats_tensor([self.batch_size, self.seq_length, self.hidden_size]						)
												A						=    ids_tensor([self.batch_size, self.seq_length]	,			vocab_size=2						)

												return (
												    config,
												    input_ids,
												    token_type_ids,
												    input_mask,
												    sequence_labels,
												    token_labels,
												    choice_labels,
												    encoder_hidden_states,
												    encoder_attention_mask,
												)


					def       lowerCamelCase			(   self     :Optional[Any]	,			__UpperCamelCase     :Optional[Any]	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :List[str]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :str	,			__UpperCamelCase     :Dict	,			__UpperCamelCase     :Union[str, Any]						):
												A						=    RemBertModel(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    model(__UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase						)
												A						=    model(__UpperCamelCase	,			token_type_ids=__UpperCamelCase						)
												A						=    model(__UpperCamelCase						)
												self.parent.assertEqual(result.last_hidden_state.shape	,			(self.batch_size, self.seq_length, self.hidden_size)						)


					def       lowerCamelCase			(   self     :Optional[Any]	,			__UpperCamelCase     :List[Any]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :List[Any]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :Optional[Any]	,			__UpperCamelCase     :Tuple	,			__UpperCamelCase     :List[Any]	,			__UpperCamelCase     :int	,			__UpperCamelCase     :Any	,			):
												A						=    True
												A						=    RemBertModel(__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    model(
												    __UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			encoder_hidden_states=__UpperCamelCase	,			encoder_attention_mask=__UpperCamelCase	,			)
												A						=    model(
												    __UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			encoder_hidden_states=__UpperCamelCase	,			)
												A						=    model(__UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase						)
												self.parent.assertEqual(result.last_hidden_state.shape	,			(self.batch_size, self.seq_length, self.hidden_size)						)


					def       lowerCamelCase			(   self     :Dict	,			__UpperCamelCase     :Any	,			__UpperCamelCase     :Any	,			__UpperCamelCase     :Tuple	,			__UpperCamelCase     :List[str]	,			__UpperCamelCase     :List[str]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Tuple	,			):
												A						=    RemBertForCausalLM(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    model(__UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			labels=__UpperCamelCase						)
												self.parent.assertEqual(result.logits.shape	,			(self.batch_size, self.seq_length, self.vocab_size)						)


					def       lowerCamelCase			(   self     :str	,			__UpperCamelCase     :List[str]	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :Any	,			__UpperCamelCase     :Dict	,			__UpperCamelCase     :Any	,			__UpperCamelCase     :Union[str, Any]						):
												A						=    RemBertForMaskedLM(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    model(__UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			labels=__UpperCamelCase						)
												self.parent.assertEqual(result.logits.shape	,			(self.batch_size, self.seq_length, self.vocab_size)						)


					def       lowerCamelCase			(   self     :Any	,			__UpperCamelCase     :List[Any]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :Optional[Any]	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :Any	,			__UpperCamelCase     :str	,			):
												A						=    True
												A						=    True
												A						=    RemBertForCausalLM(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()

												# first forward pass
												A						=    model(
												    __UpperCamelCase	,			attention_mask=__UpperCamelCase	,			encoder_hidden_states=__UpperCamelCase	,			encoder_attention_mask=__UpperCamelCase	,			use_cache=__UpperCamelCase	,			)
												A						=    outputs.past_key_values

												# create hypothetical multiple next token and extent to next_input_ids
												A						=    ids_tensor((self.batch_size, 3)	,			config.vocab_size						)
												A						=    ids_tensor((self.batch_size, 3)	,			vocab_size=2						)

												# append to next input_ids and
												A						=    torch.cat([input_ids, next_tokens]	,			dim=-1						)
												A						=    torch.cat([input_mask, next_mask]	,			dim=-1						)

												A						=    model(
												    __UpperCamelCase	,			attention_mask=__UpperCamelCase	,			encoder_hidden_states=__UpperCamelCase	,			encoder_attention_mask=__UpperCamelCase	,			output_hidden_states=__UpperCamelCase	,			)["hidden_states"][0]
												A						=    model(
												    __UpperCamelCase	,			attention_mask=__UpperCamelCase	,			encoder_hidden_states=__UpperCamelCase	,			encoder_attention_mask=__UpperCamelCase	,			past_key_values=__UpperCamelCase	,			output_hidden_states=__UpperCamelCase	,			)["hidden_states"][0]

												# select random slice
												A						=    ids_tensor((1,)	,			output_from_past.shape[-1]						).item()
												A						=    output_from_no_past[:, -3:, random_slice_idx].detach()
												A						=    output_from_past[:, :, random_slice_idx].detach()

												self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]						)

												# test that outputs are equal for slice
												self.parent.assertTrue(torch.allclose(__UpperCamelCase	,			__UpperCamelCase	,			atol=1e-3						)						)


					def       lowerCamelCase			(   self     :List[Any]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :List[str]	,			__UpperCamelCase     :List[Any]	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :Tuple						):
												A						=    RemBertForQuestionAnswering(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    model(
												    __UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			start_positions=__UpperCamelCase	,			end_positions=__UpperCamelCase	,			)
												self.parent.assertEqual(result.start_logits.shape	,			(self.batch_size, self.seq_length)						)
												self.parent.assertEqual(result.end_logits.shape	,			(self.batch_size, self.seq_length)						)


					def       lowerCamelCase			(   self     :str	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :Tuple	,			__UpperCamelCase     :Tuple	,			__UpperCamelCase     :int	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Tuple						):
												A						=    self.num_labels
												A						=    RemBertForSequenceClassification(__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    model(__UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			labels=__UpperCamelCase						)
												self.parent.assertEqual(result.logits.shape	,			(self.batch_size, self.num_labels)						)


					def       lowerCamelCase			(   self     :int	,			__UpperCamelCase     :str	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Union[str, Any]	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :str	,			__UpperCamelCase     :str						):
												A						=    self.num_labels
												A						=    RemBertForTokenClassification(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    model(__UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			labels=__UpperCamelCase						)
												self.parent.assertEqual(result.logits.shape	,			(self.batch_size, self.seq_length, self.num_labels)						)


					def       lowerCamelCase			(   self     :str	,			__UpperCamelCase     :int	,			__UpperCamelCase     :List[str]	,			__UpperCamelCase     :Optional[Any]	,			__UpperCamelCase     :Dict	,			__UpperCamelCase     :Optional[int]	,			__UpperCamelCase     :Tuple	,			__UpperCamelCase     :int						):
												A						=    self.num_choices
												A						=    RemBertForMultipleChoice(config=__UpperCamelCase						)
												model.to(__UpperCamelCase						)
												model.eval()
												A						=    input_ids.unsqueeze(1						).expand(-1	,			self.num_choices	,			-1						).contiguous()
												A						=    token_type_ids.unsqueeze(1						).expand(-1	,			self.num_choices	,			-1						).contiguous()
												A						=    input_mask.unsqueeze(1						).expand(-1	,			self.num_choices	,			-1						).contiguous()
												A						=    model(
												    __UpperCamelCase	,			attention_mask=__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			labels=__UpperCamelCase	,			)
												self.parent.assertEqual(result.logits.shape	,			(self.batch_size, self.num_choices)						)


					def       lowerCamelCase			(   self     :Dict						):
												A						=    self.prepare_config_and_inputs()
												(
												    (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      
												)						=    config_and_inputs
												A						=    {"input_ids": input_ids, "token_type_ids": token_type_ids, "attention_mask": input_mask}
												return config, inputs_dict







@require_torch
class    _UpperCAmelCase  (      lowercase_	,				lowercase_	,				unittest.TestCase					):
					UpperCamelCase						=				(
					    (
					        RemBertModel,
					        RemBertForMaskedLM,
					        RemBertForCausalLM,
					        RemBertForMultipleChoice,
					        RemBertForQuestionAnswering,
					        RemBertForSequenceClassification,
					        RemBertForTokenClassification,
					    )
					    if is_torch_available()
					    else ()
					)
					UpperCamelCase						=				(RemBertForCausalLM,) if is_torch_available() else ()
					UpperCamelCase						=				(
					    {
					        '''feature-extraction''': RemBertModel,
					        '''fill-mask''': RemBertForMaskedLM,
					        '''question-answering''': RemBertForQuestionAnswering,
					        '''text-classification''': RemBertForSequenceClassification,
					        '''text-generation''': RemBertForCausalLM,
					        '''token-classification''': RemBertForTokenClassification,
					        '''zero-shot''': RemBertForSequenceClassification,
					    }
					    if is_torch_available()
					    else {}
					)


					def       lowerCamelCase			(   self     :Dict						):
												A						=    RemBertModelTester(self						)
												A						=    ConfigTester(self	,			config_class=__UpperCamelCase	,			hidden_size=37						)


					def       lowerCamelCase			(   self     :List[Any]						):
												self.config_tester.run_common_tests()


					def       lowerCamelCase			(   self     :Any						):
												A						=    self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_model(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :str						):
												A						=    self.model_tester.prepare_config_and_inputs()
												for type in ["absolute", "relative_key", "relative_key_query"]:
																			A						=    type
																			self.model_tester.create_and_check_model(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :int						):
												A						=    self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_masked_lm(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :Optional[int]						):
												A						=    self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_multiple_choice(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :Union[str, Any]						):
												A						=    self.model_tester.prepare_config_and_inputs_for_decoder()
												self.model_tester.create_and_check_decoder_model_past_large_inputs(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :Any						):
												A						=    self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_question_answering(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :Dict						):
												A						=    self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_sequence_classification(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :Union[str, Any]						):
												A						=    self.model_tester.prepare_config_and_inputs()
												self.model_tester.create_and_check_for_token_classification(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :Optional[Any]						):
												A						=    self.model_tester.prepare_config_and_inputs_for_decoder()
												self.model_tester.create_and_check_model_as_decoder(*__UpperCamelCase						)


					def       lowerCamelCase			(   self     :int						):
												# This regression test was failing with PyTorch < 1.3
												(
												    (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      (
												    A
												),      
												)						=    self.model_tester.prepare_config_and_inputs_for_decoder()

												A						=    None

												self.model_tester.create_and_check_model_as_decoder(
												    __UpperCamelCase	,			__UpperCamelCase	,			__UpperCamelCase	,			__UpperCamelCase	,			__UpperCamelCase	,			__UpperCamelCase	,			__UpperCamelCase	,			__UpperCamelCase	,			__UpperCamelCase	,			)


					@slow
					def       lowerCamelCase			(   self     :Union[str, Any]						):
												for model_name in REMBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
																			A						=    RemBertModel.from_pretrained(__UpperCamelCase						)
																			self.assertIsNotNone(__UpperCamelCase						)







@require_torch
class    _UpperCAmelCase  (      unittest.TestCase					):


					@slow
					def       lowerCamelCase			(   self     :int						):
												# Test exact values at the last hidden layer
												A						=    RemBertModel.from_pretrained("google/rembert"						)
												A						=    torch.tensor([[3_12, 5_64_98, 3_13, 21_25, 3_13]]						)
												A						=    torch.tensor([[0, 0, 0, 1, 1]]						)
												with torch.no_grad():
																			A						=    model(__UpperCamelCase	,			token_type_ids=__UpperCamelCase	,			output_hidden_states=__UpperCamelCase						)

												A						=    11_52

												A						=    torch.Size((1, 5, hidden_size)						)
												self.assertEqual(output["last_hidden_state"].shape	,			__UpperCamelCase						)

												A						=    torch.tensor(
												    [
												        [
												            [0.0_754, -0.2_022, 0.1_904],
												            [-0.3_354, -0.3_692, -0.4_791],
												            [-0.2_314, -0.6_729, -0.0_749],
												            [-0.0_396, -0.3_105, -0.4_234],
												            [-0.1_571, -0.0_525, 0.5_353],
												        ]
												    ]						)

												# Running on the original tf implementation gives slightly different results here.
												# Not clear why this variations is present
												# TODO: Find reason for discrepancy
												# expected_original_implementation = [[
												#     [0.07630594074726105, -0.20146065950393677, 0.19107051193714142],
												#     [-0.3405614495277405, -0.36971670389175415, -0.4808273911476135],
												#     [-0.22587086260318756, -0.6656315922737122, -0.07844287157058716],
												#     [-0.04145475849509239, -0.3077218234539032, -0.42316967248916626],
												#     [-0.15887849032878876, -0.054529931396245956, 0.5356100797653198]
												# ]]

												self.assertTrue(torch.allclose(output["last_hidden_state"][:, :, :3]	,			__UpperCamelCase	,			atol=1e-4						)						)









"""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


_snake_case	:						List[str]					=					logging.get_logger(__name__)






class    _UpperCAmelCase  (      lowercase_					):
					UpperCamelCase						=				['''input_values''', '''attention_mask''']


					def __init__(   self     :str	,			__UpperCamelCase     :List[str]=1	,			__UpperCamelCase     :Tuple=1_60_00	,			__UpperCamelCase     :Optional[int]=0.0	,			__UpperCamelCase     :Optional[int]=False	,			__UpperCamelCase     :Optional[Any]=True	,			**__UpperCamelCase     :Optional[Any]	,			):
												super().__init__(feature_size=__UpperCamelCase	,			sampling_rate=__UpperCamelCase	,			padding_value=__UpperCamelCase	,			**__UpperCamelCase						)
												A						=    return_attention_mask
												A						=    do_normalize


					@staticmethod
					def       lowerCamelCase			(   __UpperCamelCase     :List[np.ndarray]	,			__UpperCamelCase     :List[np.ndarray]	,			__UpperCamelCase     :float = 0.0						):
												if attention_mask is not None:
																			A						=    np.array(__UpperCamelCase	,			np.intaa						)
																			A						=    []

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

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

												return normed_input_values


					def __call__(   self     :Tuple	,			__UpperCamelCase     :Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]]	,			__UpperCamelCase     :Union[bool, str, PaddingStrategy] = False	,			__UpperCamelCase     :Optional[int] = None	,			__UpperCamelCase     :bool = False	,			__UpperCamelCase     :Optional[int] = None	,			__UpperCamelCase     :Optional[bool] = None	,			__UpperCamelCase     :Optional[Union[str, TensorType]] = None	,			__UpperCamelCase     :Optional[int] = None	,			**__UpperCamelCase     :List[str]	,			):

												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."						)

												A						=    isinstance(__UpperCamelCase	,			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}"						)
												A						=    is_batched_numpy or (
												    isinstance(__UpperCamelCase	,			(list, tuple)						) and (isinstance(raw_speech[0]	,			(np.ndarray, tuple, list)						))
												)

												# always return batch
												if not is_batched:
																			A						=    [raw_speech]

												# convert into correct format for padding
												A						=    BatchFeature({"input_values": raw_speech}						)

												A						=    self.pad(
												    __UpperCamelCase	,			padding=__UpperCamelCase	,			max_length=__UpperCamelCase	,			truncation=__UpperCamelCase	,			pad_to_multiple_of=__UpperCamelCase	,			return_attention_mask=__UpperCamelCase	,			)

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

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

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

												if return_tensors is not None:
																			A						=    padded_inputs.convert_to_tensors(__UpperCamelCase						)

												return padded_inputs


