



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     ):



	@require_torch
	def 			__A							(       self		):
							A__							=       pipeline(
							    task="zero-shot-audio-classification"			,	model="hf-internal-testing/tiny-clap-htsat-unfused"		)
							A__							=       load_dataset("ashraq/esc50"		)
							A__							=       dataset["train"]["audio"][-1]["array"]
							A__							=       audio_classifier(UpperCAmelCase__			,	candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]		)
							self.assertEqual(
							    nested_simplify(UpperCAmelCase__		)			,	[{"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 			__A							(       self		):
							pass



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

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

							A__							=       audio_classifier([audio] * 5			,	candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]		)
							self.assertEqual(
							    nested_simplify(UpperCAmelCase__		)			,	[
							        [
							            {"score": 0.999, "label": "Sound of a dog"},
							            {"score": 0.001, "label": "Sound of vaccum cleaner"},
							        ],
							    ]
							    * 5			,	)
							A__							=       audio_classifier(
							    [audio] * 5			,	candidate_labels=["Sound of a dog", "Sound of vaccum cleaner"]			,	batch_size=5		)
							self.assertEqual(
							    nested_simplify(UpperCAmelCase__		)			,	[
							        [
							            {"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 			__A							(       self		):
							pass










def  UpperCamelCase						(       _A			:				str    )->       str:





						"""simple docstring"""





						A__							=       ""
						for ch in key:
												if ch == " " or ch not in key_no_dups and ch.isalpha():
																		key_no_dups += ch
						return key_no_dups
def  UpperCamelCase						(       _A			:				str    )->       dict[str, str]:





						"""simple docstring"""





						A__							=       [chr(i + 65    ) for i in range(26    )]
						# Remove duplicate characters from key
						A__							=       remove_duplicates(key.upper()    )
						A__							=       len(_A    )
						# First fill cipher with key characters
						A__							=       {alphabet[i]: char for i, char in enumerate(_A    )}
						# Then map remaining characters in alphabet to
						# the alphabet from the beginning
						for i in range(len(_A    )			,							26    ):
												A__							=       alphabet[i - offset]
												# Ensure we are not mapping letters to letters previously mapped
												while char in key:
																		offset -= 1
																		A__							=       alphabet[i - offset]
												A__							=       char
						return cipher_alphabet
def  UpperCamelCase						(       _A			:				str			,							_A			:				dict[str, str]    )->       str:





						"""simple docstring"""





						return "".join(cipher_map.get(_A			,							_A    ) for ch in message.upper()    )
def  UpperCamelCase						(       _A			:				str			,							_A			:				dict[str, str]    )->       str:





						"""simple docstring"""





						A__							=       {v: k for k, v in cipher_map.items()}
						return "".join(rev_cipher_map.get(_A			,							_A    ) for ch in message.upper()    )
def  UpperCamelCase						(       )->       None:





						"""simple docstring"""





						A__							=       input("Enter message to encode or decode: "    ).strip()
						A__							=       input("Enter keyword: "    ).strip()
						A__							=       input("Encipher or decipher? E/D:"    ).strip()[0].lower()
						try:
												A__							=       {"e": encipher, "d": decipher}[option]
						except KeyError:
												raise KeyError("invalid input option"    )
						A__							=       create_cipher_map(_A    )
						print(func(_A			,							_A    )    )


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						main()





