






from pathlib import Path
from typing import List

from transformers import is_torch_available, is_vision_available
from transformers.testing_utils import get_tests_dir, is_tool_test
from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText


if is_torch_available():
							import torch

if is_vision_available():
							from PIL import Image


lowercase  :							int			  =    ['text', 'image', 'audio']

def      lowerCAmelCase__	(    _a       :			List[str]    ):
		snake_case_				:							Union[str, Any]						 =       []

		for input_type in input_types:
				if input_type == "text":
						inputs.append("Text input"    )
				elif input_type == "image":
						inputs.append(
						    Image.open(Path(get_tests_dir("fixtures/tests_samples/COCO"    )    ) / "000000039769.png"    ).resize((5_12, 5_12)    )    )
				elif input_type == "audio":
						inputs.append(torch.ones(30_00    )    )
				elif isinstance(__UpperCamelCase  ,      __UpperCamelCase    ):
						inputs.append(create_inputs(__UpperCamelCase    )    )
				else:
						raise ValueError(F'''Invalid type requested: {input_type}'''    )

		return inputs

def      lowerCAmelCase__	(    _a       :			List    ):
		snake_case_				:							Any						 =       []

		for output in outputs:
				if isinstance(__UpperCamelCase  ,      (str, AgentText)    ):
						output_types.append("text"    )
				elif isinstance(__UpperCamelCase  ,      (Image.Image, AgentImage)    ):
						output_types.append("image"    )
				elif isinstance(__UpperCamelCase  ,      (torch.Tensor, AgentAudio)    ):
						output_types.append("audio"    )
				else:
						raise ValueError(F'''Invalid output: {output}'''    )

		return output_types




@is_tool_test
class 		UpperCAmelCase_						:


				'''simple docstring'''




				def       _lowerCAmelCase       (	self				) ->				List[str]:
						self.assertTrue(hasattr(self.tool		,				"inputs"				)				)
						self.assertTrue(hasattr(self.tool		,				"outputs"				)				)

						snake_case_				:							Dict						 =       self.tool.inputs
						for _input in inputs:
								if isinstance(_input		,				UpperCamelCase__				):
										for __input in _input:
												self.assertTrue(__input in authorized_types				)
								else:
										self.assertTrue(_input in authorized_types				)

						snake_case_				:							int						 =       self.tool.outputs
						for _output in outputs:
								self.assertTrue(_output in authorized_types				)






				def       _lowerCAmelCase       (	self				) ->				int:
						snake_case_				:							Optional[Any]						 =       create_inputs(self.tool.inputs				)
						snake_case_				:							Tuple						 =       self.tool(*UpperCamelCase__				)

						# There is a single output
						if len(self.tool.outputs				) == 1:
								snake_case_				:							Union[str, Any]						 =       [outputs]

						self.assertListEqual(output_types(UpperCamelCase__				)		,				self.tool.outputs				)






				def       _lowerCAmelCase       (	self				) ->				List[str]:
						self.assertTrue(hasattr(self.tool		,				"description"				)				)
						self.assertTrue(hasattr(self.tool		,				"default_checkpoint"				)				)
						self.assertTrue(self.tool.description.startswith("This is a tool that"				)				)






				def       _lowerCAmelCase       (	self				) ->				Union[str, Any]:
						snake_case_				:							Any						 =       create_inputs(self.tool.inputs				)
						snake_case_				:							Optional[Any]						 =       self.tool(*UpperCamelCase__				)

						if not isinstance(UpperCamelCase__		,				UpperCamelCase__				):
								snake_case_				:							List[Any]						 =       [outputs]

						self.assertEqual(len(UpperCamelCase__				)		,				len(self.tool.outputs				)				)

						for output, output_type in zip(UpperCamelCase__		,				self.tool.outputs				):
								snake_case_				:							List[Any]						 =       AGENT_TYPE_MAPPING[output_type]
								self.assertTrue(isinstance(UpperCamelCase__		,				UpperCamelCase__				)				)






				def       _lowerCAmelCase       (	self				) ->				Optional[Any]:
						snake_case_				:							Dict						 =       create_inputs(self.tool.inputs				)

						snake_case_				:							str						 =       []

						for _input, input_type in zip(UpperCamelCase__		,				self.tool.inputs				):
								if isinstance(UpperCamelCase__		,				UpperCamelCase__				):
										_inputs.append([AGENT_TYPE_MAPPING[_input_type](_input				) for _input_type in input_type]				)
								else:
										_inputs.append(AGENT_TYPE_MAPPING[input_type](_input				)				)

        # Should not raise an error
						snake_case_				:							Union[str, Any]						 =       self.tool(*UpperCamelCase__				)

						if not isinstance(UpperCamelCase__		,				UpperCamelCase__				):
								snake_case_				:							List[Any]						 =       [outputs]

						self.assertEqual(len(UpperCamelCase__				)		,				len(self.tool.outputs				)				)








import qiskit

def      lowerCAmelCase__	(    _a       :			int  ,      _a       :			int    ):
		snake_case_				:							Tuple						 =       qiskit.Aer.get_backend("aer_simulator"    )

		# Create a Quantum Circuit acting on the q register
		snake_case_				:							Any						 =       qiskit.QuantumCircuit(_a  ,      _a    )

		# Apply X (NOT) Gate to Qubits 0 & 1
		circuit.x(0    )
		circuit.x(1    )

		# Map the quantum measurement to the classical bits
		circuit.measure([0, 1]  ,      [0, 1]    )

		# Execute the circuit on the qasm simulator
		snake_case_				:							Any						 =       qiskit.execute(_a  ,      _a  ,      shots=10_00    )

		# Return the histogram data of the results of the experiment.
		return job.result().get_counts(_a    )


if __name__ == "__main__":
							lowercase  :							List[Any]			  =    single_qubit_measure(2, 2)
							print(F"""Total count for various states are: {counts}""")
