

"""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, prepare_image_inputs


if is_torch_available():
   import torch

if is_vision_available():
   from PIL import Image

   from transformers import MobileViTImageProcessor




class 					_lowerCAmelCase  (	unittest.TestCase   ):







 """simple docstring"""







 def __init__(			self							:			Tuple,					UpperCAmelCase__							:			List[Any],					UpperCAmelCase__							:			int=7,					UpperCAmelCase__							:			Optional[int]=3,					UpperCAmelCase__							:			Dict=1_8,					UpperCAmelCase__							:			Any=3_0,					UpperCAmelCase__							:			Any=4_0_0,					UpperCAmelCase__							:			Dict=True,					UpperCAmelCase__							:			Optional[int]=None,					UpperCAmelCase__							:			List[Any]=True,					UpperCAmelCase__							:			Union[str, Any]=None,					UpperCAmelCase__							:			int=True,					):
    __lowercase								=						size if size is not None else {"shortest_edge": 2_0}
    __lowercase								=						crop_size if crop_size is not None else {"height": 1_8, "width": 1_8}
    __lowercase								=						parent
    __lowercase								=						batch_size
    __lowercase								=						num_channels
    __lowercase								=						image_size
    __lowercase								=						min_resolution
    __lowercase								=						max_resolution
    __lowercase								=						do_resize
    __lowercase								=						size
    __lowercase								=						do_center_crop
    __lowercase								=						crop_size
    __lowercase								=						do_flip_channel_order



 def 					_lowercase (			self							:			Optional[int]	):
    return {
        "do_resize": self.do_resize,
        "size": self.size,
        "do_center_crop": self.do_center_crop,
        "crop_size": self.crop_size,
        "do_flip_channel_order": self.do_flip_channel_order,
    }







@require_torch
@require_vision
class 					_lowerCAmelCase  (	lowercase     ,unittest.TestCase   ):







 """simple docstring"""







 __UpperCAmelCase	:					Tuple   		=	MobileViTImageProcessor if is_vision_available() else None


 def 					_lowercase (			self							:			Any	):
    __lowercase								=						MobileViTImageProcessingTester(self	)


 @property
 def 					_lowercase (			self							:			Any	):
    return self.image_processor_tester.prepare_image_processor_dict()


 def 					_lowercase (			self							:			List[str]	):
    __lowercase								=						self.image_processing_class(**self.image_processor_dict	)
    self.assertTrue(hasattr(UpperCAmelCase__,					"do_resize"	)	)
    self.assertTrue(hasattr(UpperCAmelCase__,					"size"	)	)
    self.assertTrue(hasattr(UpperCAmelCase__,					"do_center_crop"	)	)
    self.assertTrue(hasattr(UpperCAmelCase__,					"center_crop"	)	)
    self.assertTrue(hasattr(UpperCAmelCase__,					"do_flip_channel_order"	)	)


 def 					_lowercase (			self							:			List[str]	):
    __lowercase								=						self.image_processing_class.from_dict(self.image_processor_dict	)
    self.assertEqual(image_processor.size,					{"shortest_edge": 2_0}	)
    self.assertEqual(image_processor.crop_size,					{"height": 1_8, "width": 1_8}	)

    __lowercase								=						self.image_processing_class.from_dict(self.image_processor_dict,					size=4_2,					crop_size=8_4	)
    self.assertEqual(image_processor.size,					{"shortest_edge": 4_2}	)
    self.assertEqual(image_processor.crop_size,					{"height": 8_4, "width": 8_4}	)


 def 					_lowercase (			self							:			str	):
    pass


 def 					_lowercase (			self							:			Any	):
    # Initialize image_processing
    __lowercase								=						self.image_processing_class(**self.image_processor_dict	)
    # create random PIL images
    __lowercase								=						prepare_image_inputs(self.image_processor_tester,					equal_resolution=UpperCAmelCase__	)
    for image in image_inputs:
       self.assertIsInstance(UpperCAmelCase__,					Image.Image	)

    # Test not batched input
    __lowercase								=						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
    __lowercase								=						image_processing(UpperCAmelCase__,					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 					_lowercase (			self							:			List[Any]	):
    # Initialize image_processing
    __lowercase								=						self.image_processing_class(**self.image_processor_dict	)
    # create random numpy tensors
    __lowercase								=						prepare_image_inputs(self.image_processor_tester,					equal_resolution=UpperCAmelCase__,					numpify=UpperCAmelCase__	)
    for image in image_inputs:
       self.assertIsInstance(UpperCAmelCase__,					np.ndarray	)

    # Test not batched input
    __lowercase								=						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
    __lowercase								=						image_processing(UpperCAmelCase__,					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 					_lowercase (			self							:			Dict	):
    # Initialize image_processing
    __lowercase								=						self.image_processing_class(**self.image_processor_dict	)
    # create random PyTorch tensors
    __lowercase								=						prepare_image_inputs(self.image_processor_tester,					equal_resolution=UpperCAmelCase__,					torchify=UpperCAmelCase__	)
    for image in image_inputs:
       self.assertIsInstance(UpperCAmelCase__,					torch.Tensor	)

    # Test not batched input
    __lowercase								=						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
    __lowercase								=						image_processing(UpperCAmelCase__,					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"],
        ),					)









import qiskit

def        a						(      _UpperCAmelCase							:					int ,   _UpperCAmelCase							:					int						):







		'''simple docstring'''





		__UpperCAmelCase    :     List[str]													=	qiskit.Aer.get_backend('''aer_simulator'''						)

		__UpperCAmelCase    :     Optional[Any]													=	qiskit.QuantumCircuit(4 ,   2						)
		# encode inputs in qubits 0 and 1
		if bita == 1:
				qc_ha.x(0						)
		if bita == 1:
				qc_ha.x(1						)
		qc_ha.barrier()

		# use cnots to write XOR of the inputs on qubit2
		qc_ha.cx(0 ,   2						)
		qc_ha.cx(1 ,   2						)

		# use ccx / toffoli gate to write AND of the inputs on qubit3
		qc_ha.ccx(0 ,   1 ,   3						)
		qc_ha.barrier()

		# extract outputs
		qc_ha.measure(2 ,   0						)  # extract XOR value
		qc_ha.measure(3 ,   1						)  # extract AND value

		# Execute the circuit on the qasm simulator
		__UpperCAmelCase    :     str													=	qiskit.execute(_UpperCAmelCase ,   _UpperCAmelCase ,   shots=10_00						)

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


if __name__ == "__main__":
				__A   			=half_adder(1, 1)
				print(f'''Half Adder Output Qubit Counts: {counts}''')





