



import inspect
import unittest

from transformers import SwinaSRConfig
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
from transformers.utils import is_torch_available, is_vision_available

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


if is_torch_available():
 import torch
 from torch import nn

 from transformers import SwinaSRForImageSuperResolution, SwinaSRModel
 from transformers.models.swinasr.modeling_swinasr import SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST

if is_vision_available():
 from PIL import Image

 from transformers import SwinaSRImageProcessor

class        _A			:



       def __init__(						self				:	List[str]	,						__SCREAMING_SNAKE_CASE				:	Optional[int]	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=13	,						__SCREAMING_SNAKE_CASE				:	List[Any]=32	,						__SCREAMING_SNAKE_CASE				:	int=1	,						__SCREAMING_SNAKE_CASE				:	List[str]=3	,						__SCREAMING_SNAKE_CASE				:	int=16	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=[1, 2, 1]	,						__SCREAMING_SNAKE_CASE				:	Dict=[2, 2, 4]	,						__SCREAMING_SNAKE_CASE				:	str=2	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=2.0	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=True	,						__SCREAMING_SNAKE_CASE				:	List[str]=0.0	,						__SCREAMING_SNAKE_CASE				:	List[str]=0.0	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=0.1	,						__SCREAMING_SNAKE_CASE				:	Union[str, Any]="gelu"	,						__SCREAMING_SNAKE_CASE				:	Dict=False	,						__SCREAMING_SNAKE_CASE				:	str=True	,						__SCREAMING_SNAKE_CASE				:	List[str]=0.02	,						__SCREAMING_SNAKE_CASE				:	List[str]=1E-5	,						__SCREAMING_SNAKE_CASE				:	List[str]=True	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=None	,						__SCREAMING_SNAKE_CASE				:	Any=False	,						__SCREAMING_SNAKE_CASE				:	Tuple=2	,						):


           '''simple docstring'''

           __a					=							parent
           __a					=							batch_size
           __a					=							image_size
           __a					=							patch_size
           __a					=							num_channels
           __a					=							embed_dim
           __a					=							depths
           __a					=							num_heads
           __a					=							window_size
           __a					=							mlp_ratio
           __a					=							qkv_bias
           __a					=							hidden_dropout_prob
           __a					=							attention_probs_dropout_prob
           __a					=							drop_path_rate
           __a					=							hidden_act
           __a					=							use_absolute_embeddings
           __a					=							patch_norm
           __a					=							layer_norm_eps
           __a					=							initializer_range
           __a					=							is_training
           __a					=							scope
           __a					=							use_labels
           __a					=							upscale

           # here we set some attributes to make tests pass
           __a					=							len(__SCREAMING_SNAKE_CASE)
           __a					=							embed_dim
           __a					=							(image_size // patch_size) ** 2



       def 						_lowerCamelCase     (						self				:	Dict):


           '''simple docstring'''

           __a					=							floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

           __a					=							None
           if self.use_labels:
               __a					=							ids_tensor([self.batch_size]	,						self.type_sequence_label_size)

           __a					=							self.get_config()

           return config, pixel_values, labels



       def 						_lowerCamelCase     (						self				:	Optional[Any]):


           '''simple docstring'''

           return SwinaSRConfig(
               image_size=self.image_size	,						patch_size=self.patch_size	,						num_channels=self.num_channels	,						embed_dim=self.embed_dim	,						depths=self.depths	,						num_heads=self.num_heads	,						window_size=self.window_size	,						mlp_ratio=self.mlp_ratio	,						qkv_bias=self.qkv_bias	,						hidden_dropout_prob=self.hidden_dropout_prob	,						attention_probs_dropout_prob=self.attention_probs_dropout_prob	,						drop_path_rate=self.drop_path_rate	,						hidden_act=self.hidden_act	,						use_absolute_embeddings=self.use_absolute_embeddings	,						path_norm=self.patch_norm	,						layer_norm_eps=self.layer_norm_eps	,						initializer_range=self.initializer_range	,						upscale=self.upscale	,						)



       def 						_lowerCamelCase     (						self				:	Optional[Any]	,						__SCREAMING_SNAKE_CASE				:	Dict	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]):


           '''simple docstring'''

           __a					=							SwinaSRModel(config=__SCREAMING_SNAKE_CASE)
           model.to(__SCREAMING_SNAKE_CASE)
           model.eval()
           __a					=							model(__SCREAMING_SNAKE_CASE)

           self.parent.assertEqual(
               result.last_hidden_state.shape	,						(self.batch_size, self.embed_dim, self.image_size, self.image_size))



       def 						_lowerCamelCase     (						self				:	Dict	,						__SCREAMING_SNAKE_CASE				:	Dict	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]	,						__SCREAMING_SNAKE_CASE				:	List[str]):


           '''simple docstring'''

           __a					=							SwinaSRForImageSuperResolution(__SCREAMING_SNAKE_CASE)
           model.to(__SCREAMING_SNAKE_CASE)
           model.eval()
           __a					=							model(__SCREAMING_SNAKE_CASE)

           __a					=							self.image_size * self.upscale
           self.parent.assertEqual(
               result.reconstruction.shape	,						(self.batch_size, self.num_channels, expected_image_size, expected_image_size))





       def 						_lowerCamelCase     (						self				:	int):


           '''simple docstring'''

           __a					=							self.prepare_config_and_inputs()
           __a			,  __a			,  __a					=							config_and_inputs
           __a					=							{'''pixel_values''': pixel_values}
           return config, inputs_dict


@require_torch
class        _A			(      __UpperCAmelCase ,__UpperCAmelCase ,unittest.TestCase       ):
       UpperCamelCase__    :       List[str]		   =		(SwinaSRModel, SwinaSRForImageSuperResolution) if is_torch_available() else ()
       UpperCamelCase__    :       Optional[int]		   =		{'''feature-extraction''': SwinaSRModel} if is_torch_available() else {}

       UpperCamelCase__    :       Dict		   =		False
       UpperCamelCase__    :       Optional[Any]		   =		False
       UpperCamelCase__    :       Optional[Any]		   =		False
       UpperCamelCase__    :       Dict		   =		False
       UpperCamelCase__    :       Tuple		   =		False



       def 						_lowerCamelCase     (						self				:	List[Any]):


           '''simple docstring'''

           __a					=							SwinaSRModelTester(self)
           __a					=							ConfigTester(self	,						config_class=__SCREAMING_SNAKE_CASE	,						embed_dim=37)



       def 						_lowerCamelCase     (						self				:	str):


           '''simple docstring'''

           self.config_tester.create_and_test_config_to_json_string()
           self.config_tester.create_and_test_config_to_json_file()
           self.config_tester.create_and_test_config_from_and_save_pretrained()
           self.config_tester.create_and_test_config_with_num_labels()
           self.config_tester.check_config_can_be_init_without_params()
           self.config_tester.check_config_arguments_init()



       def 						_lowerCamelCase     (						self				:	Union[str, Any]):


           '''simple docstring'''

           __a					=							self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_model(*__SCREAMING_SNAKE_CASE)



       def 						_lowerCamelCase     (						self				:	Tuple):


           '''simple docstring'''

           __a					=							self.model_tester.prepare_config_and_inputs()
           self.model_tester.create_and_check_for_image_super_resolution(*__SCREAMING_SNAKE_CASE)



       @unittest.skip(reason='''Got `CUDA error: misaligned address` with PyTorch 2.0.0.''')
       def 						_lowerCamelCase     (						self				:	List[Any]):


           '''simple docstring'''

           pass



       @unittest.skip(reason='''Swin2SR does not use inputs_embeds''')
       def 						_lowerCamelCase     (						self				:	Dict):


           '''simple docstring'''

           pass



       @unittest.skip(reason='''Swin2SR does not support training yet''')
       def 						_lowerCamelCase     (						self				:	Dict):


           '''simple docstring'''

           pass



       @unittest.skip(reason='''Swin2SR does not support training yet''')
       def 						_lowerCamelCase     (						self				:	Tuple):


           '''simple docstring'''

           pass



       def 						_lowerCamelCase     (						self				:	Union[str, Any]):


           '''simple docstring'''

           __a			,  __a					=							self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               __a					=							model_class(__SCREAMING_SNAKE_CASE)
               self.assertIsInstance(model.get_input_embeddings()	,						(nn.Module))
               __a					=							model.get_output_embeddings()
               self.assertTrue(x is None or isinstance(__SCREAMING_SNAKE_CASE	,						nn.Linear))



       def 						_lowerCamelCase     (						self				:	Optional[int]):


           '''simple docstring'''

           __a			,  __a					=							self.model_tester.prepare_config_and_inputs_for_common()

           for model_class in self.all_model_classes:
               __a					=							model_class(__SCREAMING_SNAKE_CASE)
               __a					=							inspect.signature(model.forward)
               # signature.parameters is an OrderedDict => so arg_names order is deterministic
               __a					=							[*signature.parameters.keys()]

               __a					=							['''pixel_values''']
               self.assertListEqual(arg_names[:1]	,						__SCREAMING_SNAKE_CASE)



       @slow
       def 						_lowerCamelCase     (						self				:	int):


           '''simple docstring'''

           for model_name in SWIN2SR_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               __a					=							SwinaSRModel.from_pretrained(__SCREAMING_SNAKE_CASE)
               self.assertIsNotNone(__SCREAMING_SNAKE_CASE)



       def 						_lowerCamelCase     (						self				:	Optional[int]):


           '''simple docstring'''

           __a			,  __a					=							self.model_tester.prepare_config_and_inputs_for_common()

           __a					=							_config_zero_init(__SCREAMING_SNAKE_CASE)
           for model_class in self.all_model_classes:
               __a					=							model_class(config=__SCREAMING_SNAKE_CASE)
               for name, param in model.named_parameters():
                   if "logit_scale" in name:
                       continue
                   if param.requires_grad:
                       self.assertIn(
                           ((param.data.mean() * 1E9).round() / 1E9).item()	,						[0.0, 1.0]	,						msg=F'Parameter {name} of model {model_class} seems not properly initialized'	,						)





       def 						_lowerCamelCase     (						self				:	Dict):


           '''simple docstring'''

           __a			,  __a					=							self.model_tester.prepare_config_and_inputs_for_common()
           __a					=							True

           for model_class in self.all_model_classes:
               __a					=							True
               __a					=							False
               __a					=							True
               __a					=							model_class(__SCREAMING_SNAKE_CASE)
               model.to(__SCREAMING_SNAKE_CASE)
               model.eval()
               with torch.no_grad():
                   __a					=							model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE))
               __a					=							outputs.attentions
               __a					=							len(self.model_tester.depths)
               self.assertEqual(len(__SCREAMING_SNAKE_CASE)	,						__SCREAMING_SNAKE_CASE)

               # check that output_attentions also work using config
               del inputs_dict["output_attentions"]
               __a					=							True
               __a					=							config.window_size**2
               __a					=							model_class(__SCREAMING_SNAKE_CASE)
               model.to(__SCREAMING_SNAKE_CASE)
               model.eval()
               with torch.no_grad():
                   __a					=							model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE))
               __a					=							outputs.attentions
               self.assertEqual(len(__SCREAMING_SNAKE_CASE)	,						__SCREAMING_SNAKE_CASE)

               self.assertListEqual(
                   list(attentions[0].shape[-3:])	,						[self.model_tester.num_heads[0], window_size_squared, window_size_squared]	,						)
               __a					=							len(__SCREAMING_SNAKE_CASE)

               # Check attention is always last and order is fine
               __a					=							True
               __a					=							True
               __a					=							model_class(__SCREAMING_SNAKE_CASE)
               model.to(__SCREAMING_SNAKE_CASE)
               model.eval()
               with torch.no_grad():
                   __a					=							model(**self._prepare_for_class(__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE))

               self.assertEqual(out_len + 1	,						len(__SCREAMING_SNAKE_CASE))

               __a					=							outputs.attentions

               self.assertEqual(len(__SCREAMING_SNAKE_CASE)	,						__SCREAMING_SNAKE_CASE)

               self.assertListEqual(
                   list(self_attentions[0].shape[-3:])	,						[self.model_tester.num_heads[0], window_size_squared, window_size_squared]	,						)


@require_vision
@require_torch
@slow
class        _A			(      unittest.TestCase       ):



       def 						_lowerCamelCase     (						self				:	Union[str, Any]):


           '''simple docstring'''

           __a					=							SwinaSRImageProcessor()
           __a					=							SwinaSRForImageSuperResolution.from_pretrained('''caidas/swin2SR-classical-sr-x2-64''').to(__SCREAMING_SNAKE_CASE)

           __a					=							Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png''')
           __a					=							processor(images=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').to(__SCREAMING_SNAKE_CASE)

           # forward pass
           with torch.no_grad():
               __a					=							model(**__SCREAMING_SNAKE_CASE)

           # verify the logits
           __a					=							torch.Size([1, 3, 976, 1_296])
           self.assertEqual(outputs.reconstruction.shape	,						__SCREAMING_SNAKE_CASE)
           __a					=							torch.tensor(
               [[0.54_58, 0.55_46, 0.56_38], [0.55_26, 0.55_65, 0.56_51], [0.53_96, 0.54_26, 0.56_21]]).to(__SCREAMING_SNAKE_CASE)
           self.assertTrue(torch.allclose(outputs.reconstruction[0, 0, :3, :3]	,						__SCREAMING_SNAKE_CASE	,						atol=1E-4))










import itertools
import random
import unittest

import numpy as np

from transformers import EncodecFeatureExtractor
from transformers.testing_utils import require_torch
from transformers.utils.import_utils import is_torch_available

from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin


if is_torch_available():
 import torch


__snake_case		:Any 						=	random.Random()





def 	__snake_case      (     _UpperCAmelCase  ,					_UpperCAmelCase=1.0  ,					_UpperCAmelCase=None  ,					_UpperCAmelCase=None							):
    if rng is None:
        __a					=							global_rng

    __a					=							[]
    for batch_idx in range(shape[0]							):
        values.append([]							)
        for _ in range(shape[1]							):
            values[-1].append(rng.random() * scale							)

    return values

@require_torch
class        _A			(      unittest.TestCase       ):



       def __init__(						self				:	Dict	,						__SCREAMING_SNAKE_CASE				:	str	,						__SCREAMING_SNAKE_CASE				:	Tuple=7	,						__SCREAMING_SNAKE_CASE				:	Any=400	,						__SCREAMING_SNAKE_CASE				:	Any=2_000	,						__SCREAMING_SNAKE_CASE				:	int=1	,						__SCREAMING_SNAKE_CASE				:	Dict=0.0	,						__SCREAMING_SNAKE_CASE				:	Optional[int]=24_000	,						__SCREAMING_SNAKE_CASE				:	Dict=True	,						):


           '''simple docstring'''

           __a					=							parent
           __a					=							batch_size
           __a					=							min_seq_length
           __a					=							max_seq_length
           __a					=							(self.max_seq_length - self.min_seq_length) // (self.batch_size - 1)
           __a					=							feature_size
           __a					=							padding_value
           __a					=							sampling_rate
           __a					=							return_attention_mask



       def 						_lowerCamelCase     (						self				:	List[str]):


           '''simple docstring'''

           return {
               "feature_size": self.feature_size,
               "padding_value": self.padding_value,
               "sampling_rate": self.sampling_rate,
               "return_attention_mask": self.return_attention_mask,
           }





       def 						_lowerCamelCase     (						self				:	List[Any]	,						__SCREAMING_SNAKE_CASE				:	Union[str, Any]=False	,						__SCREAMING_SNAKE_CASE				:	Optional[Any]=False):


           '''simple docstring'''

           def _flatten(__SCREAMING_SNAKE_CASE				:	List[str]):
               return list(itertools.chain(*__SCREAMING_SNAKE_CASE))

           if equal_length:
               __a					=							floats_list((self.batch_size, self.max_seq_length))
           else:
               # make sure that inputs increase in size
               __a					=							[
                   _flatten(floats_list((x, self.feature_size)))
                   for x in range(self.min_seq_length	,						self.max_seq_length	,						self.seq_length_diff)
               ]

           if numpify:
               __a					=							[np.asarray(__SCREAMING_SNAKE_CASE) for x in audio_inputs]

           return audio_inputs


@require_torch
class        _A			(      __UpperCAmelCase ,unittest.TestCase       ):
       UpperCamelCase__    :       str		   =		EncodecFeatureExtractor



       def 						_lowerCamelCase     (						self				:	Union[str, Any]):


           '''simple docstring'''

           __a					=							EnCodecFeatureExtractionTester(self)



       def 						_lowerCamelCase     (						self				:	Optional[int]):


           '''simple docstring'''

           __a					=							self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           # create three inputs of length 800, 1000, and 1200
           __a					=							[floats_list((1, x))[0] for x in range(800	,						1_400	,						200)]
           __a					=							[np.asarray(__SCREAMING_SNAKE_CASE) for audio_input in audio_inputs]

           # Test not batched input
           __a					=							feat_extract(audio_inputs[0]	,						return_tensors='''np''').input_values
           __a					=							feat_extract(np_audio_inputs[0]	,						return_tensors='''np''').input_values
           self.assertTrue(np.allclose(__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE	,						atol=1E-3))

           # Test batched
           __a					=							feat_extract(__SCREAMING_SNAKE_CASE	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''np''').input_values
           __a					=							feat_extract(__SCREAMING_SNAKE_CASE	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''np''').input_values
           for enc_seq_a, enc_seq_a in zip(__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE):
               self.assertTrue(np.allclose(__SCREAMING_SNAKE_CASE	,						__SCREAMING_SNAKE_CASE	,						atol=1E-3))



       def 						_lowerCamelCase     (						self				:	Optional[Any]):


           '''simple docstring'''

           __a					=							self.feature_extraction_class(**self.feat_extract_tester.prepare_feat_extract_dict())
           __a					=							np.random.rand(100).astype(np.floataa)
           __a					=							np_audio_inputs.tolist()

           for inputs in [py_audio_inputs, np_audio_inputs]:
               __a					=							feature_extractor.pad([{'''input_values''': inputs}]	,						return_tensors='''np''')
               self.assertTrue(np_processed.input_values.dtype == np.floataa)
               __a					=							feature_extractor.pad([{'''input_values''': inputs}]	,						return_tensors='''pt''')
               self.assertTrue(pt_processed.input_values.dtype == torch.floataa)



       def 						_lowerCamelCase     (						self				:	Tuple	,						__SCREAMING_SNAKE_CASE				:	str):


           '''simple docstring'''

           from datasets import load_dataset

           __a					=							load_dataset('''hf-internal-testing/librispeech_asr_dummy'''	,						'''clean'''	,						split='''validation''')
           # automatic decoding with librispeech
           __a					=							ds.sort('''id''').select(range(__SCREAMING_SNAKE_CASE))[:num_samples]['''audio''']

           return [x["array"] for x in audio_samples]



       def 						_lowerCamelCase     (						self				:	int):


           '''simple docstring'''

           __a					=							torch.tensor(
               [2.3804E-03, 2.0752E-03, 1.9836E-03, 2.1057E-03, 1.6174E-03,
                3.0518E-04, 9.1553E-05, 3.3569E-04, 9.7656E-04, 1.8311E-03,
                2.0142E-03, 2.1057E-03, 1.7395E-03, 4.5776E-04, -3.9673E-04,
                4.5776E-04, 1.0071E-03, 9.1553E-05, 4.8828E-04, 1.1597E-03,
                7.3242E-04, 9.4604E-04, 1.8005E-03, 1.8311E-03, 8.8501E-04,
                4.2725E-04, 4.8828E-04, 7.3242E-04, 1.0986E-03, 2.1057E-03])
           # fmt: on
           __a					=							self._load_datasamples(1)
           __a					=							EncodecFeatureExtractor()
           __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(input_values.shape	,						(1, 1, 93_680))
           self.assertTrue(torch.allclose(input_values[0, 0, :30]	,						__SCREAMING_SNAKE_CASE	,						atol=1E-6))



       def 						_lowerCamelCase     (						self				:	Optional[int]):


           '''simple docstring'''

           __a					=							torch.tensor(
               [2.3804E-03, 2.0752E-03, 1.9836E-03, 2.1057E-03, 1.6174E-03,
                3.0518E-04, 9.1553E-05, 3.3569E-04, 9.7656E-04, 1.8311E-03,
                2.0142E-03, 2.1057E-03, 1.7395E-03, 4.5776E-04, -3.9673E-04,
                4.5776E-04, 1.0071E-03, 9.1553E-05, 4.8828E-04, 1.1597E-03,
                7.3242E-04, 9.4604E-04, 1.8005E-03, 1.8311E-03, 8.8501E-04,
                4.2725E-04, 4.8828E-04, 7.3242E-04, 1.0986E-03, 2.1057E-03])
           # fmt: on
           __a					=							self._load_datasamples(1)
           __a					=							[np.tile(input_audio[0][None]	,						reps=(2, 1))]
           input_audio[0][1] *= 0.5
           __a					=							EncodecFeatureExtractor(feature_size=2)
           __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(input_values.shape	,						(1, 2, 93_680))
           self.assertTrue(torch.allclose(input_values[0, 0, :30]	,						__SCREAMING_SNAKE_CASE	,						atol=1E-6))
           self.assertTrue(torch.allclose(input_values[0, 1, :30]	,						EXPECTED_INPUT_VALUES * 0.5	,						atol=1E-6))





       def 						_lowerCamelCase     (						self				:	Any):


           '''simple docstring'''

           __a					=							self._load_datasamples(2)
           # would be easier if the stride was like
           __a					=							EncodecFeatureExtractor(feature_size=1	,						chunk_length_s=1	,						overlap=0.01)

           # pad and trunc raise an error ?
           with self.assertRaisesRegex(
               __SCREAMING_SNAKE_CASE	,						'''^Both padding and truncation were set. Make sure you only set one.$'''	,						):
               __a					=							feature_extractor(
                   __SCREAMING_SNAKE_CASE	,						padding='''max_length'''	,						truncation=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values

           # truncate to chunk
           __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						truncation=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(truncated_outputs.shape	,						(2, 1, 71_520))  # 2 chunks

           # force truncate to max_length
           __a					=							feature_extractor(
               __SCREAMING_SNAKE_CASE	,						truncation=__SCREAMING_SNAKE_CASE	,						max_length=48_000	,						return_tensors='''pt''').input_values
           self.assertEquals(truncated_outputs.shape	,						(2, 1, 48_000))

           # pad to chunk
           __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(padded_outputs.shape	,						(2, 1, 95_280))

           # pad to chunk
           __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(truncated_outputs.shape	,						(2, 1, 95_280))

           # force pad to max length
           __a					=							feature_extractor(
               __SCREAMING_SNAKE_CASE	,						padding='''max_length'''	,						max_length=100_000	,						return_tensors='''pt''').input_values
           self.assertEquals(truncated_outputs.shape	,						(2, 1, 100_000))

           # force no pad
           with self.assertRaisesRegex(
               __SCREAMING_SNAKE_CASE	,						'''^Unable to create tensor, you should probably activate padding with \'padding=True\' to have batched tensors with the same length.$'''	,						):
               __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values

           __a					=							feature_extractor(input_audio[0]	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(truncated_outputs.shape	,						(1, 1, 93_680))

           # no pad if no chunk_length_s
           __a					=							None
           with self.assertRaisesRegex(
               __SCREAMING_SNAKE_CASE	,						'''^Unable to create tensor, you should probably activate padding with \'padding=True\' to have batched tensors with the same length.$'''	,						):
               __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values

           __a					=							feature_extractor(input_audio[0]	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(truncated_outputs.shape	,						(1, 1, 93_680))

           # no pad if no overlap
           __a					=							2
           __a					=							None
           with self.assertRaisesRegex(
               __SCREAMING_SNAKE_CASE	,						'''^Unable to create tensor, you should probably activate padding with \'padding=True\' to have batched tensors with the same length.$'''	,						):
               __a					=							feature_extractor(__SCREAMING_SNAKE_CASE	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values

           __a					=							feature_extractor(input_audio[0]	,						padding=__SCREAMING_SNAKE_CASE	,						return_tensors='''pt''').input_values
           self.assertEquals(truncated_outputs.shape	,						(1, 1, 93_680))





