
from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


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

class     _UpperCamelCase			(   UpperCamelCase_       ,    UpperCamelCase_					):






			'''simple docstring'''

			__UpperCamelCase :  Tuple    =	"""maskformer-swin"""

			__UpperCamelCase :  Optional[int]    =	{
			    """num_attention_heads""": """num_heads""",
			    """num_hidden_layers""": """num_layers""",
			}

			def __init__(    self	:    Any  ,		snake_case_	:    Union[str, Any]=224  ,		snake_case_	:    Optional[int]=4  ,		snake_case_	:    List[str]=3  ,		snake_case_	:    Any=96  ,		snake_case_	:    List[str]=[2, 2, 6, 2]  ,		snake_case_	:    Optional[int]=[3, 6, 12, 24]  ,		snake_case_	:    str=7  ,		snake_case_	:    Any=4.0  ,		snake_case_	:    Union[str, Any]=True  ,		snake_case_	:    Optional[int]=0.0  ,		snake_case_	:    Any=0.0  ,		snake_case_	:    Union[str, Any]=0.1  ,		snake_case_	:    Optional[int]="gelu"  ,		snake_case_	:    Tuple=False  ,		snake_case_	:    Dict=0.02  ,		snake_case_	:    List[Any]=1e-5  ,		snake_case_	:    List[str]=None  ,		snake_case_	:    Dict=None  ,		**snake_case_	:    Dict  ,		):
							super().__init__(**_a )

							UpperCamelCase_:							Tuple		=  image_size
							UpperCamelCase_:							Dict		=  patch_size
							UpperCamelCase_:							int		=  num_channels
							UpperCamelCase_:							Any		=  embed_dim
							UpperCamelCase_:							Dict		=  depths
							UpperCamelCase_:							Tuple		=  len(_a )
							UpperCamelCase_:							Optional[int]		=  num_heads
							UpperCamelCase_:							Optional[int]		=  window_size
							UpperCamelCase_:							Any		=  mlp_ratio
							UpperCamelCase_:							Any		=  qkv_bias
							UpperCamelCase_:							List[str]		=  hidden_dropout_prob
							UpperCamelCase_:							Optional[Any]		=  attention_probs_dropout_prob
							UpperCamelCase_:							Any		=  drop_path_rate
							UpperCamelCase_:							str		=  hidden_act
							UpperCamelCase_:							Any		=  use_absolute_embeddings
							UpperCamelCase_:							Optional[Any]		=  layer_norm_eps
							UpperCamelCase_:							Optional[Any]		=  initializer_range
							# we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
							# this indicates the channel dimension after the last stage of the model
							UpperCamelCase_:							Dict		=  int(embed_dim * 2 ** (len(_a ) - 1) )
							UpperCamelCase_:							str		=  ["""stem"""] + [f'''stage{idx}''' for idx in range(1  ,		len(_a ) + 1 )]
							UpperCamelCase_:							str		=  get_aligned_output_features_output_indices(
							    out_features=_a  ,		out_indices=_a  ,		stage_names=self.stage_names )








import unittest

from datasets import load_dataset

from transformers.pipelines import pipeline
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow

@is_pipeline_test
@require_torch
class     _UpperCamelCase			(   unittest.TestCase					):






			'''simple docstring'''

			@require_torch
			def  lowerCAmelCase__		(    self	:    Dict ):
							UpperCamelCase_:							Any		=  pipeline(
							    task="""zero-shot-audio-classification"""  ,		model="""hf-internal-testing/tiny-clap-htsat-unfused""" )
							UpperCamelCase_:							str		=  load_dataset("""ashraq/esc50""" )
							UpperCamelCase_:							Optional[int]		=  dataset["""train"""]["""audio"""][-1]["""array"""]
							UpperCamelCase_:							Optional[int]		=  audio_classifier(snake_case_  ,		candidate_labels=["""Sound of a dog""", """Sound of vaccum cleaner"""] )
							self.assertEqual(
							    nested_simplify(snake_case_ )  ,		[{"""score""": 0.501, """label""": """Sound of a dog"""}, {"""score""": 0.499, """label""": """Sound of vaccum cleaner"""}]  ,		)

			@unittest.skip("""No models are available in TF""" )
			def  lowerCAmelCase__		(    self	:    Optional[Any] ):
							pass

			@slow
			@require_torch
			def  lowerCAmelCase__		(    self	:    int ):
							UpperCamelCase_:							List[str]		=  pipeline(
							    task="""zero-shot-audio-classification"""  ,		model="""laion/clap-htsat-unfused"""  ,		)
							# This is an audio of a dog
							UpperCamelCase_:							Tuple		=  load_dataset("""ashraq/esc50""" )
							UpperCamelCase_:							Optional[int]		=  dataset["""train"""]["""audio"""][-1]["""array"""]
							UpperCamelCase_:							int		=  audio_classifier(snake_case_  ,		candidate_labels=["""Sound of a dog""", """Sound of vaccum cleaner"""] )

							self.assertEqual(
							    nested_simplify(snake_case_ )  ,		[
							        {"""score""": 0.999, """label""": """Sound of a dog"""},
							        {"""score""": 0.001, """label""": """Sound of vaccum cleaner"""},
							    ]  ,		)

							UpperCamelCase_:							Any		=  audio_classifier([audio] * 5  ,		candidate_labels=["""Sound of a dog""", """Sound of vaccum cleaner"""] )
							self.assertEqual(
							    nested_simplify(snake_case_ )  ,		[
							        [
							            {"""score""": 0.999, """label""": """Sound of a dog"""},
							            {"""score""": 0.001, """label""": """Sound of vaccum cleaner"""},
							        ],
							    ]
							    * 5  ,		)
							UpperCamelCase_:							Any		=  audio_classifier(
							    [audio] * 5  ,		candidate_labels=["""Sound of a dog""", """Sound of vaccum cleaner"""]  ,		batch_size=5 )
							self.assertEqual(
							    nested_simplify(snake_case_ )  ,		[
							        [
							            {"""score""": 0.999, """label""": """Sound of a dog"""},
							            {"""score""": 0.001, """label""": """Sound of vaccum cleaner"""},
							        ],
							    ]
							    * 5  ,		)




			@unittest.skip("""No models are available in TF""" )
			def  lowerCAmelCase__		(    self	:    Optional[Any] ):
							pass






