






'''simple docstring'''





import collections
import inspect
import unittest

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

from ...test_backbone_common import BackboneTesterMixin
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 SwinBackbone, SwinForImageClassification, SwinForMaskedImageModeling, SwinModel
							from transformers.models.swin.modeling_swin import SWIN_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
							from PIL import Image

							from transformers import AutoImageProcessor





class 		SCREAMING_SNAKE_CASE__   :



		def __init__(    self:    List[str]				,   a:    Optional[Any]				,   a:    Dict=13				,   a:    List[Any]=32				,   a:    Union[str, Any]=2				,   a:    Optional[int]=3				,   a:    Optional[Any]=16				,   a:    Dict=[1, 2, 1]				,   a:    str=[2, 2, 4]				,   a:    Any=2				,   a:    List[Any]=2.0				,   a:    List[str]=True				,   a:    List[Any]=0.0				,   a:    Optional[Any]=0.0				,   a:    List[str]=0.1				,   a:    Optional[Any]="gelu"				,   a:    Dict=False				,   a:    List[Any]=True				,   a:    List[str]=0.02				,   a:    Optional[Any]=1e-5				,   a:    str=True				,   a:    Optional[int]=None				,   a:    Union[str, Any]=True				,   a:    List[str]=10				,   a:    List[str]=8				,   a:    int=["stage1", "stage2"]				,   a:    List[str]=[1, 2]				,   )  ->List[str]:






								'''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_				     =   type_sequence_label_size
								a_				     =   encoder_stride
								a_				     =   out_features
								a_				     =   out_indices



		def _lowerCAmelCase     (    self:    Optional[int])  ->Union[str, Any]:






								'''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:    Any)  ->int:






								'''simple docstring'''


								return SwinConfig(
								    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				,   encoder_stride=self.encoder_stride				,   out_features=self.out_features				,   out_indices=self.out_indices				,   )



		def _lowerCAmelCase     (    self:    Dict				,   a:    Tuple				,   a:    List[Any]				,   a:    Dict)  ->int:






								'''simple docstring'''


								a_				     =   SwinModel(config=a)
								model.to(a)
								model.eval()
								a_				     =   model(a)

								a_				     =   ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths) - 1))
								a_				     =   int(config.embed_dim * 2 ** (len(config.depths) - 1))

								self.parent.assertEqual(result.last_hidden_state.shape				,   (self.batch_size, expected_seq_len, expected_dim))



		def _lowerCAmelCase     (    self:    Dict				,   a:    Optional[int]				,   a:    Optional[Any]				,   a:    List[str])  ->Optional[int]:






								'''simple docstring'''


								a_				     =   SwinBackbone(config=a)
								model.to(a)
								model.eval()
								a_				     =   model(a)

								# verify hidden states
								self.parent.assertEqual(len(result.feature_maps)				,   len(config.out_features))
								self.parent.assertListEqual(list(result.feature_maps[0].shape)				,   [self.batch_size, model.channels[0], 16, 16])

								# verify channels
								self.parent.assertEqual(len(model.channels)				,   len(config.out_features))

								# verify backbone works with out_features=None
								a_				     =   None
								a_				     =   SwinBackbone(config=a)
								model.to(a)
								model.eval()
								a_				     =   model(a)

								# verify feature maps
								self.parent.assertEqual(len(result.feature_maps)				,   1)
								self.parent.assertListEqual(list(result.feature_maps[0].shape)				,   [self.batch_size, model.channels[-1], 4, 4])

								# verify channels
								self.parent.assertEqual(len(model.channels)				,   1)



		def _lowerCAmelCase     (    self:    List[Any]				,   a:    List[str]				,   a:    Any				,   a:    Optional[int])  ->str:






								'''simple docstring'''


								a_				     =   SwinForMaskedImageModeling(config=a)
								model.to(a)
								model.eval()
								a_				     =   model(a)
								self.parent.assertEqual(
								    result.logits.shape				,   (self.batch_size, self.num_channels, self.image_size, self.image_size))

								# test greyscale images
								a_				     =   1
								a_				     =   SwinForMaskedImageModeling(a)
								model.to(a)
								model.eval()

								a_				     =   floats_tensor([self.batch_size, 1, self.image_size, self.image_size])
								a_				     =   model(a)
								self.parent.assertEqual(result.logits.shape				,   (self.batch_size, 1, self.image_size, self.image_size))



		def _lowerCAmelCase     (    self:    Any				,   a:    Union[str, Any]				,   a:    int				,   a:    str)  ->Tuple:






								'''simple docstring'''


								a_				     =   self.type_sequence_label_size
								a_				     =   SwinForImageClassification(a)
								model.to(a)
								model.eval()
								a_				     =   model(a				,   labels=a)
								self.parent.assertEqual(result.logits.shape				,   (self.batch_size, self.type_sequence_label_size))

								# test greyscale images
								a_				     =   1
								a_				     =   SwinForImageClassification(a)
								model.to(a)
								model.eval()

								a_				     =   floats_tensor([self.batch_size, 1, self.image_size, self.image_size])
								a_				     =   model(a)
								self.parent.assertEqual(result.logits.shape				,   (self.batch_size, self.type_sequence_label_size))




		def _lowerCAmelCase     (    self:    str)  ->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 		SCREAMING_SNAKE_CASE__   (     lowercase_		,		lowercase_		,		unittest.TestCase    ):
		_UpperCAmelCase         =(
		    (
		        SwinModel,
		        SwinBackbone,
		        SwinForImageClassification,
		        SwinForMaskedImageModeling,
		    )
		    if is_torch_available()
		    else ()
		)
		_UpperCAmelCase         =(
		    {'''feature-extraction''': SwinModel, '''image-classification''': SwinForImageClassification}
		    if is_torch_available()
		    else {}
		)
		_UpperCAmelCase         =True

		_UpperCAmelCase         =False
		_UpperCAmelCase         =False
		_UpperCAmelCase         =False



		def _lowerCAmelCase     (    self:    Dict)  ->Optional[Any]:






								'''simple docstring'''


								a_				     =   SwinModelTester(self)
								a_				     =   ConfigTester(self				,   config_class=a				,   embed_dim=37)



		def _lowerCAmelCase     (    self:    List[Any])  ->Optional[Any]:






								'''simple docstring'''


								self.create_and_test_config_common_properties()
								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:    str)  ->Any:






								'''simple docstring'''


								return



		def _lowerCAmelCase     (    self:    List[str])  ->Tuple:






								'''simple docstring'''


								a_				     =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_model(*a)



		@unittest.skip(reason="Got `CUDA error: misaligned address` with PyTorch 2.0.0.")
		def _lowerCAmelCase     (    self:    List[str])  ->Any:






								'''simple docstring'''


								pass



		def _lowerCAmelCase     (    self:    Any)  ->Union[str, Any]:






								'''simple docstring'''


								super().test_training_gradient_checkpointing()



		def _lowerCAmelCase     (    self:    Tuple)  ->Optional[int]:






								'''simple docstring'''


								a_				     =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_backbone(*a)



		def _lowerCAmelCase     (    self:    List[str])  ->int:






								'''simple docstring'''


								a_				     =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_masked_image_modeling(*a)



		def _lowerCAmelCase     (    self:    Dict)  ->Optional[Any]:






								'''simple docstring'''


								a_				     =   self.model_tester.prepare_config_and_inputs()
								self.model_tester.create_and_check_for_image_classification(*a)



		@unittest.skip(reason="Swin does not use inputs_embeds")
		def _lowerCAmelCase     (    self:    Optional[Any])  ->int:






								'''simple docstring'''


								pass



		@unittest.skip(reason="Swin Transformer does not use feedforward chunking")
		def _lowerCAmelCase     (    self:    List[Any])  ->Optional[Any]:






								'''simple docstring'''


								pass



		def _lowerCAmelCase     (    self:    Dict)  ->Dict:






								'''simple docstring'''


								a_     ,       a_				     =   self.model_tester.prepare_config_and_inputs_for_common()

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



		def _lowerCAmelCase     (    self:    Optional[int])  ->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(a)
														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]				,   a)



		def _lowerCAmelCase     (    self:    Dict)  ->Optional[int]:






								'''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(a)
														model.to(a)
														model.eval()
														with torch.no_grad():
																				a_				     =   model(**self._prepare_for_class(a				,   a))
														a_				     =   outputs.attentions
														a_				     =   len(self.model_tester.depths)
														self.assertEqual(len(a)				,   a)

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

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

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

														# also another +1 for reshaped_hidden_states
														a_				     =   1 if model_class.__name__ == "SwinBackbone" else 2
														self.assertEqual(out_len + added_hidden_states				,   len(a))

														a_				     =   outputs.attentions

														self.assertEqual(len(a)				,   a)

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



		def _lowerCAmelCase     (    self:    List[str]				,   a:    Dict				,   a:    Dict				,   a:    Tuple				,   a:    str)  ->int:






								'''simple docstring'''


								a_				     =   model_class(a)
								model.to(a)
								model.eval()

								with torch.no_grad():
														a_				     =   model(**self._prepare_for_class(a				,   a))

								a_				     =   outputs.hidden_states

								a_				     =   getattr(
								    self.model_tester				,   "expected_num_hidden_layers"				,   len(self.model_tester.depths) + 1)
								self.assertEqual(len(a)				,   a)

								# Swin has a different seq_length
								a_				     =   (
								    config.patch_size
								    if isinstance(config.patch_size				,   collections.abc.Iterable)
								    else (config.patch_size, config.patch_size)
								)

								a_				     =   (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

								self.assertListEqual(
								    list(hidden_states[0].shape[-2:])				,   [num_patches, self.model_tester.embed_dim]				,   )

								if not model_class.__name__ == "SwinBackbone":
														a_				     =   outputs.reshaped_hidden_states
														self.assertEqual(len(a)				,   a)

														a_     ,       a_     ,       a_     ,       a_				     =   reshaped_hidden_states[0].shape
														a_				     =   (
														    reshaped_hidden_states[0].view(a				,   a				,   height * width).permute(0				,   2				,   1)
														)
														self.assertListEqual(
														    list(reshaped_hidden_states.shape[-2:])				,   [num_patches, self.model_tester.embed_dim]				,   )



		def _lowerCAmelCase     (    self:    List[str])  ->Optional[int]:






								'''simple docstring'''


								a_     ,       a_				     =   self.model_tester.prepare_config_and_inputs_for_common()

								a_				     =   (
								    self.model_tester.image_size
								    if isinstance(self.model_tester.image_size				,   collections.abc.Iterable)
								    else (self.model_tester.image_size, self.model_tester.image_size)
								)

								for model_class in self.all_model_classes:
														a_				     =   True
														self.check_hidden_states_output(a				,   a				,   a				,   a)

														# check that output_hidden_states also work using config
														del inputs_dict["output_hidden_states"]
														a_				     =   True

														self.check_hidden_states_output(a				,   a				,   a				,   a)



		def _lowerCAmelCase     (    self:    List[Any])  ->Any:






								'''simple docstring'''


								a_     ,       a_				     =   self.model_tester.prepare_config_and_inputs_for_common()
								a_				     =   3

								a_				     =   (
								    self.model_tester.image_size
								    if isinstance(self.model_tester.image_size				,   collections.abc.Iterable)
								    else (self.model_tester.image_size, self.model_tester.image_size)
								)
								a_				     =   (
								    config.patch_size
								    if isinstance(config.patch_size				,   collections.abc.Iterable)
								    else (config.patch_size, config.patch_size)
								)

								a_				     =   image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
								a_				     =   image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

								for model_class in self.all_model_classes:
														a_				     =   True
														self.check_hidden_states_output(a				,   a				,   a				,   (padded_height, padded_width))

														# check that output_hidden_states also work using config
														del inputs_dict["output_hidden_states"]
														a_				     =   True
														self.check_hidden_states_output(a				,   a				,   a				,   (padded_height, padded_width))



		@slow
		def _lowerCAmelCase     (    self:    List[Any])  ->Dict:






								'''simple docstring'''


								for model_name in SWIN_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
														a_				     =   SwinModel.from_pretrained(a)
														self.assertIsNotNone(a)




		def _lowerCAmelCase     (    self:    Tuple)  ->Dict:






								'''simple docstring'''


								a_     ,       a_				     =   self.model_tester.prepare_config_and_inputs_for_common()

								a_				     =   _config_zero_init(a)
								for model_class in self.all_model_classes:
														a_				     =   model_class(config=a)
														for name, param in model.named_parameters():
																				if "embeddings" not in name and 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"""				,   )





@require_vision
@require_torch
class 		SCREAMING_SNAKE_CASE__   (     unittest.TestCase    ):



		@cached_property
		def _lowerCAmelCase     (    self:    int)  ->int:






								'''simple docstring'''


								return (
								    AutoImageProcessor.from_pretrained("microsoft/swin-tiny-patch4-window7-224")
								    if is_vision_available()
								    else None
								)




		@slow
		def _lowerCAmelCase     (    self:    Optional[Any])  ->Optional[Any]:






								'''simple docstring'''


								a_				     =   SwinForImageClassification.from_pretrained("microsoft/swin-tiny-patch4-window7-224").to(a)
								a_				     =   self.default_image_processor

								a_				     =   Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png")
								a_				     =   image_processor(images=a				,   return_tensors="pt").to(a)

								# forward pass
								with torch.no_grad():
														a_				     =   model(**a)

								# verify the logits
								a_				     =   torch.Size((1, 10_00))
								self.assertEqual(outputs.logits.shape				,   a)
								a_				     =   torch.tensor([-0.0948, -0.6454, -0.0921]).to(a)
								self.assertTrue(torch.allclose(outputs.logits[0, :3]				,   a				,   atol=1e-4))





@require_torch
class 		SCREAMING_SNAKE_CASE__   (     unittest.TestCase		,		lowercase_    ):
		_UpperCAmelCase         =(SwinBackbone,) if is_torch_available() else ()
		_UpperCAmelCase         =SwinConfig



		def _lowerCAmelCase     (    self:    Any)  ->Tuple:






								'''simple docstring'''


								a_				     =   SwinModelTester(self)











'''simple docstring'''





import json
import os
import shutil
import tempfile
import unittest

from transformers import is_speech_available, is_torch_available
from transformers.models.speechta import SpeechTaTokenizer
from transformers.testing_utils import get_tests_dir, require_torch
from transformers.utils import FEATURE_EXTRACTOR_NAME


if is_speech_available() and is_torch_available():
							from transformers import SpeechTaFeatureExtractor, SpeechTaProcessor

							from .test_feature_extraction_speechta import floats_list


a_      = get_tests_dir('fixtures/test_sentencepiece_bpe_char.model')





@require_torch
class 		SCREAMING_SNAKE_CASE__   (     unittest.TestCase    ):



		def _lowerCAmelCase     (    self:    str)  ->Optional[Any]:






								'''simple docstring'''


								a_				     =   tempfile.mkdtemp()

								a_				     =   SpeechTaTokenizer(a)
								tokenizer.save_pretrained(self.tmpdirname)

								a_				     =   {
								    "feature_size": 1,
								    "padding_value": 0.0,
								    "sampling_rate": 1_60_00,
								    "do_normalize": False,
								    "num_mel_bins": 80,
								    "hop_length": 16,
								    "win_length": 64,
								    "win_function": "hann_window",
								    "fmin": 80,
								    "fmax": 76_00,
								    "mel_floor": 1e-10,
								    "reduction_factor": 2,
								    "return_attention_mask": True,
								}

								a_				     =   os.path.join(self.tmpdirname				,   a)
								with open(self.feature_extraction_file				,   "w"				,   encoding="utf-8") as fp:
														fp.write(json.dumps(a) + "\n")



		def _lowerCAmelCase     (    self:    Any				,   **a:    List[Any])  ->Optional[Any]:






								'''simple docstring'''


								return SpeechTaTokenizer.from_pretrained(self.tmpdirname				,   **a)



		def _lowerCAmelCase     (    self:    Union[str, Any]				,   **a:    int)  ->str:






								'''simple docstring'''


								return SpeechTaFeatureExtractor.from_pretrained(self.tmpdirname				,   **a)



		def _lowerCAmelCase     (    self:    int)  ->Optional[Any]:






								'''simple docstring'''


								shutil.rmtree(self.tmpdirname)



		def _lowerCAmelCase     (    self:    Any)  ->str:






								'''simple docstring'''


								a_				     =   self.get_tokenizer()
								a_				     =   self.get_feature_extractor()

								a_				     =   SpeechTaProcessor(tokenizer=a				,   feature_extractor=a)

								processor.save_pretrained(self.tmpdirname)
								a_				     =   SpeechTaProcessor.from_pretrained(self.tmpdirname)

								self.assertEqual(processor.tokenizer.get_vocab()				,   tokenizer.get_vocab())
								self.assertIsInstance(processor.tokenizer				,   a)

								self.assertEqual(processor.feature_extractor.to_json_string()				,   feature_extractor.to_json_string())
								self.assertIsInstance(processor.feature_extractor				,   a)



		def _lowerCAmelCase     (    self:    List[Any])  ->Optional[int]:






								'''simple docstring'''


								a_				     =   SpeechTaProcessor(tokenizer=self.get_tokenizer()				,   feature_extractor=self.get_feature_extractor())
								processor.save_pretrained(self.tmpdirname)

								a_				     =   self.get_tokenizer(bos_token="(BOS)"				,   eos_token="(EOS)")
								a_				     =   self.get_feature_extractor(do_normalize=a				,   padding_value=1.0)

								a_				     =   SpeechTaProcessor.from_pretrained(
								    self.tmpdirname				,   bos_token="(BOS)"				,   eos_token="(EOS)"				,   do_normalize=a				,   padding_value=1.0)

								self.assertEqual(processor.tokenizer.get_vocab()				,   tokenizer_add_kwargs.get_vocab())
								self.assertIsInstance(processor.tokenizer				,   a)

								self.assertEqual(processor.feature_extractor.to_json_string()				,   feature_extractor_add_kwargs.to_json_string())
								self.assertIsInstance(processor.feature_extractor				,   a)



		def _lowerCAmelCase     (    self:    Any)  ->List[Any]:






								'''simple docstring'''


								a_				     =   self.get_feature_extractor()
								a_				     =   self.get_tokenizer()

								a_				     =   SpeechTaProcessor(tokenizer=a				,   feature_extractor=a)

								a_				     =   floats_list((3, 10_00))

								a_				     =   feature_extractor(audio=a				,   return_tensors="np")
								a_				     =   processor(audio=a				,   return_tensors="np")

								for key in input_feat_extract.keys():
														self.assertAlmostEqual(input_feat_extract[key].sum()				,   input_processor[key].sum()				,   delta=1e-2)



		def _lowerCAmelCase     (    self:    Tuple)  ->Union[str, Any]:






								'''simple docstring'''


								a_				     =   self.get_feature_extractor()
								a_				     =   self.get_tokenizer()

								a_				     =   SpeechTaProcessor(tokenizer=a				,   feature_extractor=a)

								a_				     =   floats_list((3, 10_00))

								a_				     =   feature_extractor(audio_target=a				,   return_tensors="np")
								a_				     =   processor(audio_target=a				,   return_tensors="np")

								for key in input_feat_extract.keys():
														self.assertAlmostEqual(input_feat_extract[key].sum()				,   input_processor[key].sum()				,   delta=1e-2)



		def _lowerCAmelCase     (    self:    str)  ->Dict:






								'''simple docstring'''


								a_				     =   self.get_feature_extractor()
								a_				     =   self.get_tokenizer()

								a_				     =   SpeechTaProcessor(tokenizer=a				,   feature_extractor=a)

								a_				     =   "This is a test string"

								a_				     =   processor(text=a)
								a_				     =   tokenizer(a)

								for key in encoded_tok.keys():
														self.assertListEqual(encoded_tok[key]				,   encoded_processor[key])



		def _lowerCAmelCase     (    self:    List[Any])  ->Any:






								'''simple docstring'''


								a_				     =   self.get_feature_extractor()
								a_				     =   self.get_tokenizer()

								a_				     =   SpeechTaProcessor(tokenizer=a				,   feature_extractor=a)

								a_				     =   "This is a test string"

								a_				     =   processor(text_target=a)
								a_				     =   tokenizer(a)

								for key in encoded_tok.keys():
														self.assertListEqual(encoded_tok[key]				,   encoded_processor[key])



		def _lowerCAmelCase     (    self:    List[Any])  ->Any:






								'''simple docstring'''


								a_				     =   self.get_feature_extractor()
								a_				     =   self.get_tokenizer()

								a_				     =   SpeechTaProcessor(tokenizer=a				,   feature_extractor=a)

								a_				     =   [[1, 4, 5, 8, 1, 0, 8], [3, 4, 3, 1, 1, 8, 9]]

								a_				     =   processor.batch_decode(a)
								a_				     =   tokenizer.batch_decode(a)

								self.assertListEqual(a				,   a)




		def _lowerCAmelCase     (    self:    Optional[int])  ->Optional[int]:






								'''simple docstring'''


								a_				     =   self.get_feature_extractor()
								a_				     =   self.get_tokenizer()

								a_				     =   SpeechTaProcessor(tokenizer=a				,   feature_extractor=a)

								self.assertListEqual(
								    processor.model_input_names				,   feature_extractor.model_input_names				,   msg="`processor` and `feature_extractor` model input names do not match"				,   )



