



from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_DEFAULT_MEAN,
    IMAGENET_DEFAULT_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
				import PIL


__A   			=logging.get_logger(__name__)

class 		UpperCAmelCase__			(			__UpperCamelCase   ):




			'''simple docstring'''






			UpperCamelCase									=       ["""pixel_values"""]




			def __init__(   self							: Optional[Any]       ,       a_							: bool = True       ,       a_							: Dict[str, int] = None       ,       a_							: int = 0.9       ,       a_							: PILImageResampling = PILImageResampling.BICUBIC       ,       a_							: bool = True       ,       a_							: Dict[str, int] = None       ,       a_							: Union[int, float] = 1 / 2_55       ,       a_							: bool = True       ,       a_							: bool = True       ,       a_							: Optional[Union[float, List[float]]] = None       ,       a_							: Optional[Union[float, List[float]]] = None       ,       **a_							: Optional[Any]       ,       ):
					'''simple docstring'''





					super().__init__(**a_ )
					__UpperCAmelCase    :     List[Any]													=	size if size is not None else {'''shortest_edge''': 2_24}
					__UpperCAmelCase    :     List[Any]													=	get_size_dict(a_       ,       default_to_square=a_ )
					__UpperCAmelCase    :     str													=	crop_size if crop_size is not None else {'''height''': 2_24, '''width''': 2_24}
					__UpperCAmelCase    :     Optional[int]													=	get_size_dict(a_       ,       param_name='''crop_size''' )

					__UpperCAmelCase    :     Optional[int]													=	do_resize
					__UpperCAmelCase    :     Optional[Any]													=	size
					__UpperCAmelCase    :     str													=	crop_pct
					__UpperCAmelCase    :     Dict													=	resample
					__UpperCAmelCase    :     Union[str, Any]													=	do_center_crop
					__UpperCAmelCase    :     Optional[int]													=	crop_size
					__UpperCAmelCase    :     Union[str, Any]													=	do_rescale
					__UpperCAmelCase    :     Optional[int]													=	rescale_factor
					__UpperCAmelCase    :     Any													=	do_normalize
					__UpperCAmelCase    :     Optional[int]													=	image_mean if image_mean is not None else IMAGENET_DEFAULT_MEAN
					__UpperCAmelCase    :     Optional[int]													=	image_std if image_std is not None else IMAGENET_DEFAULT_STD




			def  snake_case__     (   self							: int       ,       a_							: np.ndarray       ,       a_							: Dict[str, int]       ,       a_							: Optional[float] = None       ,       a_							: PILImageResampling = PILImageResampling.BICUBIC       ,       a_							: Optional[Union[str, ChannelDimension]] = None       ,       **a_							: List[Any]       ,       ):
					'''simple docstring'''





					__UpperCAmelCase    :     List[str]													=	get_size_dict(a_       ,       default_to_square=a_ )
					if "shortest_edge" not in size and ("height" not in size or "width" not in size):
							raise ValueError(F'size must contain \'height\' and \'width\' or \'shortest_edge\' as keys. Got {size.keys()}' )
					if crop_pct is not None:
							if "shortest_edge" in size:
									__UpperCAmelCase    :     Optional[Any]													=	int(size['''shortest_edge'''] / crop_pct )
							elif "height" in size and "width" in size:
									if size["height"] == size["width"]:
											__UpperCAmelCase    :     Union[str, Any]													=	int(size['''height'''] / crop_pct )
									else:
											__UpperCAmelCase    :     Optional[Any]													=	(int(size['''height'''] / crop_pct ), int(size['''width'''] / crop_pct ))
							else:
									raise ValueError('''Invalid size for resize: {}'''.format(a_ ) )

							__UpperCAmelCase    :     Optional[int]													=	get_resize_output_image_size(a_       ,       size=a_       ,       default_to_square=a_ )
					else:
							if "shortest_edge" in size:
									__UpperCAmelCase    :     int													=	get_resize_output_image_size(a_       ,       size=size['''shortest_edge''']       ,       default_to_square=a_ )
							elif "height" in size and "width" in size:
									__UpperCAmelCase    :     List[Any]													=	(size['''height'''], size['''width'''])
							else:
									raise ValueError('''Invalid size for resize: {}'''.format(a_ ) )

					return resize(a_       ,       size=a_       ,       resample=a_       ,       data_format=a_       ,       **a_ )




			def  snake_case__     (   self							: Union[str, Any]       ,       a_							: np.ndarray       ,       a_							: Dict[str, int]       ,       a_							: Optional[Union[str, ChannelDimension]] = None       ,       **a_							: int       ,       ):
					'''simple docstring'''





					__UpperCAmelCase    :     str													=	get_size_dict(a_ )
					if "height" not in size or "width" not in size:
							raise ValueError(F'size must contain \'height\' and \'width\' as keys. Got {size.keys()}' )
					return center_crop(a_       ,       size=(size['''height'''], size['''width'''])       ,       data_format=a_       ,       **a_ )




			def  snake_case__     (   self							: str       ,       a_							: np.ndarray       ,       a_							: Union[int, float]       ,       a_							: Optional[Union[str, ChannelDimension]] = None       ,       **a_							: Optional[Any]       ,       ):
					'''simple docstring'''





					return rescale(a_       ,       scale=a_       ,       data_format=a_       ,       **a_ )




			def  snake_case__     (   self							: Union[str, Any]       ,       a_							: np.ndarray       ,       a_							: Union[float, List[float]]       ,       a_							: Union[float, List[float]]       ,       a_							: Optional[Union[str, ChannelDimension]] = None       ,       **a_							: List[str]       ,       ):
					'''simple docstring'''





					return normalize(a_       ,       mean=a_       ,       std=a_       ,       data_format=a_       ,       **a_ )




			def  snake_case__     (   self							: str       ,       a_							: ImageInput       ,       a_							: bool = None       ,       a_							: Dict[str, int] = None       ,       a_							: int = None       ,       a_							: PILImageResampling = None       ,       a_							: bool = None       ,       a_							: Dict[str, int] = None       ,       a_							: bool = None       ,       a_							: float = None       ,       a_							: bool = None       ,       a_							: Optional[Union[float, List[float]]] = None       ,       a_							: Optional[Union[float, List[float]]] = None       ,       a_							: Optional[Union[str, TensorType]] = None       ,       a_							: ChannelDimension = ChannelDimension.FIRST       ,       **a_							: str       ,       ):
					'''simple docstring'''





					__UpperCAmelCase    :     List[str]													=	do_resize if do_resize is not None else self.do_resize
					__UpperCAmelCase    :     int													=	crop_pct if crop_pct is not None else self.crop_pct
					__UpperCAmelCase    :     Optional[int]													=	resample if resample is not None else self.resample
					__UpperCAmelCase    :     List[str]													=	do_center_crop if do_center_crop is not None else self.do_center_crop
					__UpperCAmelCase    :     Dict													=	do_rescale if do_rescale is not None else self.do_rescale
					__UpperCAmelCase    :     Optional[int]													=	rescale_factor if rescale_factor is not None else self.rescale_factor
					__UpperCAmelCase    :     int													=	do_normalize if do_normalize is not None else self.do_normalize
					__UpperCAmelCase    :     Any													=	image_mean if image_mean is not None else self.image_mean
					__UpperCAmelCase    :     Any													=	image_std if image_std is not None else self.image_std

					__UpperCAmelCase    :     Optional[int]													=	size if size is not None else self.size
					__UpperCAmelCase    :     Optional[Any]													=	get_size_dict(a_       ,       default_to_square=a_ )
					__UpperCAmelCase    :     Any													=	crop_size if crop_size is not None else self.crop_size
					__UpperCAmelCase    :     Union[str, Any]													=	get_size_dict(a_       ,       param_name='''crop_size''' )

					__UpperCAmelCase    :     Any													=	make_list_of_images(a_ )

					if not valid_images(a_ ):
							raise ValueError(
							    '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
							    '''torch.Tensor, tf.Tensor or jax.ndarray.''' )

					if do_resize and size is None or resample is None:
							raise ValueError('''Size and resample must be specified if do_resize is True.''' )

					if do_center_crop and crop_pct is None:
							raise ValueError('''Crop_pct must be specified if do_center_crop is True.''' )

					if do_rescale and rescale_factor is None:
							raise ValueError('''Rescale factor must be specified if do_rescale is True.''' )

					if do_normalize and (image_mean is None or image_std is None):
							raise ValueError('''Image mean and std must be specified if do_normalize is True.''' )

					# All transformations expect numpy arrays.
					__UpperCAmelCase    :     Tuple													=	[to_numpy_array(a_ ) for image in images]

					if do_resize:
							__UpperCAmelCase    :     Tuple													=	[self.resize(image=a_       ,       size=a_       ,       crop_pct=a_       ,       resample=a_ ) for image in images]

					if do_center_crop:
							__UpperCAmelCase    :     Optional[int]													=	[self.center_crop(image=a_       ,       size=a_ ) for image in images]

					if do_rescale:
							__UpperCAmelCase    :     str													=	[self.rescale(image=a_       ,       scale=a_ ) for image in images]

					if do_normalize:
							__UpperCAmelCase    :     Union[str, Any]													=	[self.normalize(image=a_       ,       mean=a_       ,       std=a_ ) for image in images]

					__UpperCAmelCase    :     Optional[int]													=	[to_channel_dimension_format(a_       ,       a_ ) for image in images]

					__UpperCAmelCase    :     Union[str, Any]													=	{'''pixel_values''': images}
					return BatchFeature(data=a_       ,       tensor_type=a_ )










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}''')





