
"""simple docstring"""


import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
		import torch

if is_vision_available():
		from PIL import Image

		from transformers import ChineseCLIPImageProcessor







class 					lowerCAmelCase_					(   unittest.TestCase     ):



						'''simple docstring'''


						def __init__(			self  :   List[str]	,A_  :   Tuple	,A_  :   List[Any]=7	,A_  :   Dict=3	,A_  :   Any=18	,A_  :   List[Any]=30	,A_  :   List[Any]=400	,A_  :   List[Any]=True	,A_  :   Optional[int]=None	,A_  :   int=True	,A_  :   Any=None	,A_  :   Optional[Any]=True	,A_  :   Union[str, Any]=[0.48_14_54_66, 0.4_57_82_75, 0.40_82_10_73]	,A_  :   str=[0.26_86_29_54, 0.26_13_02_58, 0.27_57_77_11]	,A_  :   Union[str, Any]=True	,)  -> int:
							A     = size if size is not None else {'height': 224, 'width': 224}
							A     = crop_size if crop_size is not None else {'height': 18, 'width': 18}
							A     = parent
							A     = batch_size
							A     = num_channels
							A     = image_size
							A     = min_resolution
							A     = max_resolution
							A     = do_resize
							A     = size
							A     = do_center_crop
							A     = crop_size
							A     = do_normalize
							A     = image_mean
							A     = image_std
							A     = do_convert_rgb


						def     _SCREAMING_SNAKE_CASE   (			self  :   Any   )  -> Optional[int]:
							return {
							    "do_resize": self.do_resize,
							    "size": self.size,
							    "do_center_crop": self.do_center_crop,
							    "crop_size": self.crop_size,
							    "do_normalize": self.do_normalize,
							    "image_mean": self.image_mean,
							    "image_std": self.image_std,
							    "do_convert_rgb": self.do_convert_rgb,
							}




						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]	,A_  :   List[Any]=False	,A_  :   List[str]=False	,A_  :   Optional[Any]=False   )  -> List[Any]:
							assert not (numpify and torchify), "You cannot specify both numpy and PyTorch tensors at the same time"

							if equal_resolution:
								A     = []
								for i in range(self.batch_size   ):
									image_inputs.append(
									    np.random.randint(
									        255	,size=(self.num_channels, self.max_resolution, self.max_resolution)	,dtype=np.uinta   )   )
							else:
								A     = []
								for i in range(self.batch_size   ):
									A ,   A     = np.random.choice(np.arange(self.min_resolution	,self.max_resolution   )	,2   )
									image_inputs.append(np.random.randint(255	,size=(self.num_channels, width, height)	,dtype=np.uinta   )   )

							if not numpify and not torchify:
								# PIL expects the channel dimension as last dimension
								A     = [Image.fromarray(np.moveaxis(A_	,0	,-1   )   ) for x in image_inputs]

							if torchify:
								A     = [torch.from_numpy(A_   ) for x in image_inputs]

							return image_inputs







@require_torch
@require_vision
class 					lowerCAmelCase_					(   _lowercase		,       unittest.TestCase     ):



						'''simple docstring'''


						_lowerCamelCase:     Tuple   =     ChineseCLIPImageProcessor if is_vision_available() else None


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]   )  -> Union[str, Any]:
							A     = ChineseCLIPImageProcessingTester(self	,do_center_crop=A_   )


						@property
						def     _SCREAMING_SNAKE_CASE   (			self  :   int   )  -> Dict:
							return self.image_processor_tester.prepare_image_processor_dict()


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]   )  -> int:
							A     = self.image_processing_class(**self.image_processor_dict   )
							self.assertTrue(hasattr(A_	,'do_resize'   )   )
							self.assertTrue(hasattr(A_	,'size'   )   )
							self.assertTrue(hasattr(A_	,'do_center_crop'   )   )
							self.assertTrue(hasattr(A_	,'center_crop'   )   )
							self.assertTrue(hasattr(A_	,'do_normalize'   )   )
							self.assertTrue(hasattr(A_	,'image_mean'   )   )
							self.assertTrue(hasattr(A_	,'image_std'   )   )
							self.assertTrue(hasattr(A_	,'do_convert_rgb'   )   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]   )  -> Union[str, Any]:
							A     = self.image_processing_class.from_dict(self.image_processor_dict   )
							self.assertEqual(image_processor.size	,{'height': 224, 'width': 224}   )
							self.assertEqual(image_processor.crop_size	,{'height': 18, 'width': 18}   )

							A     = self.image_processing_class.from_dict(self.image_processor_dict	,size=42	,crop_size=84   )
							self.assertEqual(image_processor.size	,{'shortest_edge': 42}   )
							self.assertEqual(image_processor.crop_size	,{'height': 84, 'width': 84}   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]   )  -> str:
							pass


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]   )  -> Optional[int]:
							# Initialize image_processing
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random PIL images
							A     = self.image_processor_tester.prepare_inputs(equal_resolution=A_   )
							for image in image_inputs:
								self.assertIsInstance(A_	,Image.Image   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)

							# Test batched
							A     = image_processing(A_	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]   )  -> Dict:
							# Initialize image_processing
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random numpy tensors
							A     = self.image_processor_tester.prepare_inputs(equal_resolution=A_	,numpify=A_   )
							for image in image_inputs:
								self.assertIsInstance(A_	,np.ndarray   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)

							# Test batched
							A     = image_processing(A_	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)




						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> Any:
							# Initialize image_processing
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random PyTorch tensors
							A     = self.image_processor_tester.prepare_inputs(equal_resolution=A_	,torchify=A_   )
							for image in image_inputs:
								self.assertIsInstance(A_	,torch.Tensor   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        1,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)

							# Test batched
							A     = image_processing(A_	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        self.image_processor_tester.batch_size,
							        self.image_processor_tester.num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)







@require_torch
@require_vision
class 					lowerCAmelCase_					(   _lowercase		,       unittest.TestCase     ):



						'''simple docstring'''


						_lowerCamelCase:     Dict   =     ChineseCLIPImageProcessor if is_vision_available() else None


						def     _SCREAMING_SNAKE_CASE   (			self  :   Any   )  -> List[str]:
							A     = ChineseCLIPImageProcessingTester(self	,num_channels=4	,do_center_crop=A_   )
							A     = 3


						@property
						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]   )  -> Any:
							return self.image_processor_tester.prepare_image_processor_dict()


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]   )  -> Any:
							A     = self.image_processing_class(**self.image_processor_dict   )
							self.assertTrue(hasattr(A_	,'do_resize'   )   )
							self.assertTrue(hasattr(A_	,'size'   )   )
							self.assertTrue(hasattr(A_	,'do_center_crop'   )   )
							self.assertTrue(hasattr(A_	,'center_crop'   )   )
							self.assertTrue(hasattr(A_	,'do_normalize'   )   )
							self.assertTrue(hasattr(A_	,'image_mean'   )   )
							self.assertTrue(hasattr(A_	,'image_std'   )   )
							self.assertTrue(hasattr(A_	,'do_convert_rgb'   )   )


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




						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[int]   )  -> List[str]:
							# Initialize image_processing
							A     = self.image_processing_class(**self.image_processor_dict   )
							# create random PIL images
							A     = self.image_processor_tester.prepare_inputs(equal_resolution=A_   )
							for image in image_inputs:
								self.assertIsInstance(A_	,Image.Image   )

							# Test not batched input
							A     = image_processing(image_inputs[0]	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        1,
							        self.expected_encoded_image_num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)

							# Test batched
							A     = image_processing(A_	,return_tensors='pt'   ).pixel_values
							self.assertEqual(
							    encoded_images.shape	,(
							        self.image_processor_tester.batch_size,
							        self.expected_encoded_image_num_channels,
							        self.image_processor_tester.crop_size['height'],
							        self.image_processor_tester.crop_size['width'],
							    )	,)



import qiskit
def 							__lowerCamelCase		(					UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						int		):




      """simple docstring"""





      a		:Tuple									=			qiskit.Aer.get_backend('''aer_simulator'''		)

      # Create a Quantum Circuit acting on the q register
      a		:str									=			qiskit.QuantumCircuit(UpperCAmelCase_					,    UpperCAmelCase_		)

      # 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
      a		:Optional[Any]									=			qiskit.execute(UpperCAmelCase_					,    UpperCAmelCase_					,    shots=1000		)

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


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





