






'''simple docstring'''

import unittest

from transformers import (
    MODEL_FOR_OBJECT_DETECTION_MAPPING,
    AutoFeatureExtractor,
    AutoModelForObjectDetection,
    ObjectDetectionPipeline,
    is_vision_available,
    pipeline,
)
from transformers.testing_utils import (
    is_pipeline_test,
    nested_simplify,
    require_pytesseract,
    require_tf,
    require_timm,
    require_torch,
    require_vision,
    slow,
)

from .test_pipelines_common import ANY


if is_vision_available():
      from PIL import Image
else:




      class      A     :






       """simple docstring"""





       @staticmethod
       def 	_UpperCAmelCase							(				*__lowerCAmelCase      ,  **__lowerCAmelCase			):
             pass




@is_pipeline_test
@require_vision
@require_timm
@require_torch
class      A     (   unittest.TestCase    ):






 """simple docstring"""





 __a      :    Tuple			  =    MODEL_FOR_OBJECT_DETECTION_MAPPING
 def 	_UpperCAmelCase							(				self      ,  __lowerCAmelCase      ,  __lowerCAmelCase      ,  __lowerCAmelCase			):
       UpperCamelCase_					: Any            =				ObjectDetectionPipeline(model=_A      ,  image_processor=_A			)
       return object_detector, ["./tests/fixtures/tests_samples/COCO/000000039769.png"]
 def 	_UpperCAmelCase							(				self      ,  __lowerCAmelCase      ,  __lowerCAmelCase			):
       UpperCamelCase_					: Any            =				object_detector("""./tests/fixtures/tests_samples/COCO/000000039769.png"""      ,  threshold=0.0			)

       self.assertGreater(len(_A			)      ,  0			)
       for detected_object in outputs:
             self.assertEqual(
                 _A      ,  {
                     """score""": ANY(_A			),
                     """label""": ANY(_A			),
                     """box""": {"""xmin""": ANY(_A			), """ymin""": ANY(_A			), """xmax""": ANY(_A			), """ymax""": ANY(_A			)},
                 }      ,  )

       import datasets

       UpperCamelCase_					: int            =				datasets.load_dataset("""hf-internal-testing/fixtures_image_utils"""      ,  """image"""      ,  split="""test"""			)

       UpperCamelCase_					: Optional[int]            =				[
           Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""			),
           """http://images.cocodataset.org/val2017/000000039769.jpg""",
           # RGBA
           dataset[0]["""file"""],
           # LA
           dataset[1]["""file"""],
           # L
           dataset[2]["""file"""],
       ]
       UpperCamelCase_					: Dict            =				object_detector(_A      ,  threshold=0.0			)

       self.assertEqual(len(_A			)      ,  len(_A			)			)
       for outputs in batch_outputs:
             self.assertGreater(len(_A			)      ,  0			)
             for detected_object in outputs:
                   self.assertEqual(
                       _A      ,  {
                           """score""": ANY(_A			),
                           """label""": ANY(_A			),
                           """box""": {"""xmin""": ANY(_A			), """ymin""": ANY(_A			), """xmax""": ANY(_A			), """ymax""": ANY(_A			)},
                       }      ,  )
 @require_tf
 @unittest.skip("""Object detection not implemented in TF"""			)
 def 	_UpperCAmelCase							(				self			):
       pass
 @require_torch
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: int            =				"""hf-internal-testing/tiny-detr-mobilenetsv3"""

       UpperCamelCase_					: Optional[int]            =				AutoModelForObjectDetection.from_pretrained(_A			)
       UpperCamelCase_					: List[Any]            =				AutoFeatureExtractor.from_pretrained(_A			)
       UpperCamelCase_					: Tuple            =				ObjectDetectionPipeline(model=_A      ,  feature_extractor=_A			)

       UpperCamelCase_					: Dict            =				object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""      ,  threshold=0.0			)

       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               {"""score""": 0.33_76, """label""": """LABEL_0""", """box""": {"""xmin""": 1_59, """ymin""": 1_20, """xmax""": 4_80, """ymax""": 3_59}},
               {"""score""": 0.33_76, """label""": """LABEL_0""", """box""": {"""xmin""": 1_59, """ymin""": 1_20, """xmax""": 4_80, """ymax""": 3_59}},
           ]      ,  )

       UpperCamelCase_					: int            =				object_detector(
           [
               """http://images.cocodataset.org/val2017/000000039769.jpg""",
               """http://images.cocodataset.org/val2017/000000039769.jpg""",
           ]      ,  threshold=0.0      ,  )

       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               [
                   {"""score""": 0.33_76, """label""": """LABEL_0""", """box""": {"""xmin""": 1_59, """ymin""": 1_20, """xmax""": 4_80, """ymax""": 3_59}},
                   {"""score""": 0.33_76, """label""": """LABEL_0""", """box""": {"""xmin""": 1_59, """ymin""": 1_20, """xmax""": 4_80, """ymax""": 3_59}},
               ],
               [
                   {"""score""": 0.33_76, """label""": """LABEL_0""", """box""": {"""xmin""": 1_59, """ymin""": 1_20, """xmax""": 4_80, """ymax""": 3_59}},
                   {"""score""": 0.33_76, """label""": """LABEL_0""", """box""": {"""xmin""": 1_59, """ymin""": 1_20, """xmax""": 4_80, """ymax""": 3_59}},
               ],
           ]      ,  )
 @require_torch
 @slow
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: Any            =				"""facebook/detr-resnet-50"""

       UpperCamelCase_					: int            =				AutoModelForObjectDetection.from_pretrained(_A			)
       UpperCamelCase_					: Union[str, Any]            =				AutoFeatureExtractor.from_pretrained(_A			)
       UpperCamelCase_					: Dict            =				ObjectDetectionPipeline(model=_A      ,  feature_extractor=_A			)

       UpperCamelCase_					: Dict            =				object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""			)
       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               {"""score""": 0.99_82, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 1_75, """ymax""": 1_17}},
               {"""score""": 0.99_60, """label""": """remote""", """box""": {"""xmin""": 3_33, """ymin""": 72, """xmax""": 3_68, """ymax""": 1_87}},
               {"""score""": 0.99_55, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 6_39, """ymax""": 4_73}},
               {"""score""": 0.99_88, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 3_14, """ymax""": 4_70}},
               {"""score""": 0.99_87, """label""": """cat""", """box""": {"""xmin""": 3_45, """ymin""": 23, """xmax""": 6_40, """ymax""": 3_68}},
           ]      ,  )

       UpperCamelCase_					: Optional[int]            =				object_detector(
           [
               """http://images.cocodataset.org/val2017/000000039769.jpg""",
               """http://images.cocodataset.org/val2017/000000039769.jpg""",
           ]			)
       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               [
                   {"""score""": 0.99_82, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 1_75, """ymax""": 1_17}},
                   {"""score""": 0.99_60, """label""": """remote""", """box""": {"""xmin""": 3_33, """ymin""": 72, """xmax""": 3_68, """ymax""": 1_87}},
                   {"""score""": 0.99_55, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 6_39, """ymax""": 4_73}},
                   {"""score""": 0.99_88, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 3_14, """ymax""": 4_70}},
                   {"""score""": 0.99_87, """label""": """cat""", """box""": {"""xmin""": 3_45, """ymin""": 23, """xmax""": 6_40, """ymax""": 3_68}},
               ],
               [
                   {"""score""": 0.99_82, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 1_75, """ymax""": 1_17}},
                   {"""score""": 0.99_60, """label""": """remote""", """box""": {"""xmin""": 3_33, """ymin""": 72, """xmax""": 3_68, """ymax""": 1_87}},
                   {"""score""": 0.99_55, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 6_39, """ymax""": 4_73}},
                   {"""score""": 0.99_88, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 3_14, """ymax""": 4_70}},
                   {"""score""": 0.99_87, """label""": """cat""", """box""": {"""xmin""": 3_45, """ymin""": 23, """xmax""": 6_40, """ymax""": 3_68}},
               ],
           ]      ,  )
 @require_torch
 @slow
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: List[Any]            =				"""facebook/detr-resnet-50"""

       UpperCamelCase_					: Optional[Any]            =				pipeline("""object-detection"""      ,  model=_A			)

       UpperCamelCase_					: Optional[Any]            =				object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""			)
       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               {"""score""": 0.99_82, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 1_75, """ymax""": 1_17}},
               {"""score""": 0.99_60, """label""": """remote""", """box""": {"""xmin""": 3_33, """ymin""": 72, """xmax""": 3_68, """ymax""": 1_87}},
               {"""score""": 0.99_55, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 6_39, """ymax""": 4_73}},
               {"""score""": 0.99_88, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 3_14, """ymax""": 4_70}},
               {"""score""": 0.99_87, """label""": """cat""", """box""": {"""xmin""": 3_45, """ymin""": 23, """xmax""": 6_40, """ymax""": 3_68}},
           ]      ,  )

       UpperCamelCase_					: int            =				object_detector(
           [
               """http://images.cocodataset.org/val2017/000000039769.jpg""",
               """http://images.cocodataset.org/val2017/000000039769.jpg""",
           ]			)
       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               [
                   {"""score""": 0.99_82, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 1_75, """ymax""": 1_17}},
                   {"""score""": 0.99_60, """label""": """remote""", """box""": {"""xmin""": 3_33, """ymin""": 72, """xmax""": 3_68, """ymax""": 1_87}},
                   {"""score""": 0.99_55, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 6_39, """ymax""": 4_73}},
                   {"""score""": 0.99_88, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 3_14, """ymax""": 4_70}},
                   {"""score""": 0.99_87, """label""": """cat""", """box""": {"""xmin""": 3_45, """ymin""": 23, """xmax""": 6_40, """ymax""": 3_68}},
               ],
               [
                   {"""score""": 0.99_82, """label""": """remote""", """box""": {"""xmin""": 40, """ymin""": 70, """xmax""": 1_75, """ymax""": 1_17}},
                   {"""score""": 0.99_60, """label""": """remote""", """box""": {"""xmin""": 3_33, """ymin""": 72, """xmax""": 3_68, """ymax""": 1_87}},
                   {"""score""": 0.99_55, """label""": """couch""", """box""": {"""xmin""": 0, """ymin""": 1, """xmax""": 6_39, """ymax""": 4_73}},
                   {"""score""": 0.99_88, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 3_14, """ymax""": 4_70}},
                   {"""score""": 0.99_87, """label""": """cat""", """box""": {"""xmin""": 3_45, """ymin""": 23, """xmax""": 6_40, """ymax""": 3_68}},
               ],
           ]      ,  )
 @require_torch
 @slow
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: Optional[Any]            =				0.99_85
       UpperCamelCase_					: Tuple            =				"""facebook/detr-resnet-50"""

       UpperCamelCase_					: Dict            =				pipeline("""object-detection"""      ,  model=_A			)

       UpperCamelCase_					: str            =				object_detector("""http://images.cocodataset.org/val2017/000000039769.jpg"""      ,  threshold=_A			)
       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               {"""score""": 0.99_88, """label""": """cat""", """box""": {"""xmin""": 13, """ymin""": 52, """xmax""": 3_14, """ymax""": 4_70}},
               {"""score""": 0.99_87, """label""": """cat""", """box""": {"""xmin""": 3_45, """ymin""": 23, """xmax""": 6_40, """ymax""": 3_68}},
           ]      ,  )





 @require_torch
 @require_pytesseract
 @slow
 def 	_UpperCAmelCase							(				self			):
       UpperCamelCase_					: List[Any]            =				"""Narsil/layoutlmv3-finetuned-funsd"""
       UpperCamelCase_					: Optional[int]            =				0.99_93

       UpperCamelCase_					: List[Any]            =				pipeline("""object-detection"""      ,  model=_A      ,  threshold=_A			)

       UpperCamelCase_					: Tuple            =				object_detector(
           """https://huggingface.co/spaces/impira/docquery/resolve/2359223c1837a7587402bda0f2643382a6eefeab/invoice.png"""			)
       self.assertEqual(
           nested_simplify(_A      ,  decimals=4			)      ,  [
               {"""score""": 0.99_93, """label""": """I-ANSWER""", """box""": {"""xmin""": 2_94, """ymin""": 2_54, """xmax""": 3_43, """ymax""": 2_64}},
               {"""score""": 0.99_93, """label""": """I-ANSWER""", """box""": {"""xmin""": 2_94, """ymin""": 2_54, """xmax""": 3_43, """ymax""": 2_64}},
           ]      ,  )













"""simple docstring"""


import inspect
import unittest

from huggingface_hub import hf_hub_download

from transformers import ASTConfig
from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_torchaudio_available

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


if is_torch_available():
		import torch
		from torch import nn

		from transformers import ASTForAudioClassification, ASTModel
		from transformers.models.audio_spectrogram_transformer.modeling_audio_spectrogram_transformer import (
		    AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
		)


if is_torchaudio_available():
		import torchaudio

		from transformers import ASTFeatureExtractor






class 							lowercase__			:

			"""simple docstring"""







			def __init__(      self						,   _A						,   _A=1_3						,   _A=2						,   _A=2_4						,   _A=1_6						,   _A=True						,   _A=True						,   _A=3_2						,   _A=5						,   _A=4						,   _A=3_7						,   _A="gelu"						,   _A=0.1						,   _A=0.1						,   _A=1_0						,   _A=0.02						,   _A=None						,   _A=2						,   _A=2						,   ):






									'''simple docstring'''







									UpperCamelCase				:		Tuple				   =			parent
									UpperCamelCase				:		str				   =			batch_size
									UpperCamelCase				:		Optional[Any]				   =			patch_size
									UpperCamelCase				:		Optional[int]				   =			max_length
									UpperCamelCase				:		str				   =			num_mel_bins
									UpperCamelCase				:		Optional[int]				   =			is_training
									UpperCamelCase				:		str				   =			use_labels
									UpperCamelCase				:		Optional[int]				   =			hidden_size
									UpperCamelCase				:		Union[str, Any]				   =			num_hidden_layers
									UpperCamelCase				:		Optional[Any]				   =			num_attention_heads
									UpperCamelCase				:		Union[str, Any]				   =			intermediate_size
									UpperCamelCase				:		str				   =			hidden_act
									UpperCamelCase				:		Optional[Any]				   =			hidden_dropout_prob
									UpperCamelCase				:		Dict				   =			attention_probs_dropout_prob
									UpperCamelCase				:		Union[str, Any]				   =			type_sequence_label_size
									UpperCamelCase				:		List[Any]				   =			initializer_range
									UpperCamelCase				:		Optional[Any]				   =			scope
									UpperCamelCase				:		List[Any]				   =			frequency_stride
									UpperCamelCase				:		Tuple				   =			time_stride

									# in AST, the seq length equals the number of patches + 2 (we add 2 for the [CLS] and distillation tokens)
									UpperCamelCase				:		Optional[Any]				   =			(self.num_mel_bins - self.patch_size) // self.frequency_stride + 1
									UpperCamelCase				:		Dict				   =			(self.max_length - self.patch_size) // self.time_stride + 1
									UpperCamelCase				:		List[str]				   =			frequency_out_dimension * time_out_dimension
									UpperCamelCase				:		int				   =			num_patches + 2







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		Optional[int]				   =			floats_tensor([self.batch_size, self.max_length, self.num_mel_bins]    )

									UpperCamelCase				:		int				   =			None
									if self.use_labels:
															UpperCamelCase				:		Tuple				   =			ids_tensor([self.batch_size]						,   self.type_sequence_label_size    )

									UpperCamelCase				:		Dict				   =			self.get_config()

									return config, input_values, labels







			def   _a      (      self    ):






									'''simple docstring'''







									return ASTConfig(
									    patch_size=self.patch_size						,   max_length=self.max_length						,   num_mel_bins=self.num_mel_bins						,   hidden_size=self.hidden_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						,   is_decoder=_A						,   initializer_range=self.initializer_range						,   frequency_stride=self.frequency_stride						,   time_stride=self.time_stride						,   )







			def   _a      (      self						,   _A						,   _A						,   _A    ):






									'''simple docstring'''







									UpperCamelCase				:		List[str]				   =			ASTModel(config=_A    )
									model.to(_A    )
									model.eval()
									UpperCamelCase				:		int				   =			model(_A    )
									self.parent.assertEqual(result.last_hidden_state.shape						,   (self.batch_size, self.seq_length, self.hidden_size)    )







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		Optional[Any]				   =			self.prepare_config_and_inputs()
									(
									    (
									    UpperCamelCase
									)   ,						(
									    UpperCamelCase
									)   ,						(
									    UpperCamelCase
									)   ,						
									)				:		List[str]				   =			config_and_inputs
									UpperCamelCase				:		Union[str, Any]				   =			{"""input_values""": input_values}
									return config, inputs_dict






@require_torch
class 							lowercase__			(   __SCREAMING_SNAKE_CASE					,     __SCREAMING_SNAKE_CASE					,     unittest.TestCase	):

			"""simple docstring"""
			__lowerCAmelCase     :				List[Any]										=  (
			    (
			        ASTModel,
			        ASTForAudioClassification,
			    )
			    if is_torch_available()
			    else ()
			)
			__lowerCAmelCase     :				Any										=  (
			    {"""audio-classification""": ASTForAudioClassification, """feature-extraction""": ASTModel}
			    if is_torch_available()
			    else {}
			)
			__lowerCAmelCase     :				Union[str, Any]										=  False
			__lowerCAmelCase     :				Any										=  False
			__lowerCAmelCase     :				List[Any]										=  False
			__lowerCAmelCase     :				Union[str, Any]										=  False







			def   _a      (      self						,   _A						,   _A						,   _A						,   _A						,   _A    ):






									'''simple docstring'''







									if pipeline_test_casse_name == "AudioClassificationPipelineTests":
															return True

									return False







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		str				   =			ASTModelTester(self    )
									UpperCamelCase				:		int				   =			ConfigTester(self						,   config_class=_A						,   has_text_modality=_A						,   hidden_size=3_7    )







			def   _a      (      self    ):






									'''simple docstring'''







									self.config_tester.run_common_tests()







			@unittest.skip(reason="""AST does not use inputs_embeds"""    )
			def   _a      (      self    ):






									'''simple docstring'''







									pass







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase   ,						UpperCamelCase				:		int				   =			self.model_tester.prepare_config_and_inputs_for_common()

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







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase   ,						UpperCamelCase				:		Union[str, Any]				   =			self.model_tester.prepare_config_and_inputs_for_common()

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

															UpperCamelCase				:		Any				   =			["""input_values"""]
															self.assertListEqual(arg_names[:1]						,   _A    )







			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		int				   =			self.model_tester.prepare_config_and_inputs()
									self.model_tester.create_and_check_model(*_A    )







			@slow
			def   _a      (      self    ):






									'''simple docstring'''







									for model_name in AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
															UpperCamelCase				:		int				   =			ASTModel.from_pretrained(_A    )
															self.assertIsNotNone(_A    )


def      UpperCamelCase							():
						UpperCamelCase				:		Optional[Any]				   =			hf_hub_download(
						    repo_id="""nielsr/audio-spectogram-transformer-checkpoint"""							,     filename="""sample_audio.flac"""							,     repo_type="""dataset"""     )

						UpperCamelCase   ,						UpperCamelCase				:		Dict				   =			torchaudio.load(SCREAMING_SNAKE_CASE     )

						return audio, sampling_rate






@require_torch
@require_torchaudio
class 							lowercase__			(   unittest.TestCase	):

			"""simple docstring"""







			@cached_property
			def   _a      (      self    ):






									'''simple docstring'''







									return (
									    ASTFeatureExtractor.from_pretrained("""MIT/ast-finetuned-audioset-10-10-0.4593"""    )
									    if is_torchaudio_available()
									    else None
									)







			@slow
			def   _a      (      self    ):






									'''simple docstring'''







									UpperCamelCase				:		Union[str, Any]				   =			self.default_feature_extractor
									UpperCamelCase				:		Any				   =			ASTForAudioClassification.from_pretrained("""MIT/ast-finetuned-audioset-10-10-0.4593"""    ).to(_A    )

									UpperCamelCase				:		Union[str, Any]				   =			self.default_feature_extractor
									UpperCamelCase   ,						UpperCamelCase				:		List[Any]				   =			prepare_audio()
									UpperCamelCase				:		Optional[Any]				   =			audio.squeeze().numpy()
									UpperCamelCase				:		Union[str, Any]				   =			feature_extractor(_A						,   sampling_rate=_A						,   return_tensors="""pt"""    ).to(_A    )

									# forward pass
									with torch.no_grad():
															UpperCamelCase				:		Optional[Any]				   =			model(**_A    )

									# verify the logits
									UpperCamelCase				:		List[Any]				   =			torch.Size((1, 5_2_7)    )
									self.assertEqual(outputs.logits.shape						,   _A    )

									UpperCamelCase				:		Optional[Any]				   =			torch.tensor([-0.87_60, -7.00_42, -8.66_02]    ).to(_A    )

									self.assertTrue(torch.allclose(outputs.logits[0, :3]						,   _A						,   atol=1e-4    )    )



