



"""simple docstring"""







import argparse
import os
import re


# All paths are set with the intent you should run this script from the root of the repo with the command
# python utils/check_dummies.py
lowerCAmelCase_   						=   'src/diffusers'

# Matches is_xxx_available()
lowerCAmelCase_   						=   re.compile(R'is\_([a-z_]*)_available\(\)')
# Matches from xxx import bla
lowerCAmelCase_   						=   re.compile(R'\s+from\s+\S*\s+import\s+([^\(\s].*)\n')


lowerCAmelCase_   						=   '\n{0} = None\n'

lowerCAmelCase_   						=   '\nclass {0}(metaclass=DummyObject):\n    _backends = {1}\n\n    def __init__(self, *args, **kwargs):\n        requires_backends(self, {1})\n\n    @classmethod\n    def from_config(cls, *args, **kwargs):\n        requires_backends(cls, {1})\n\n    @classmethod\n    def from_pretrained(cls, *args, **kwargs):\n        requires_backends(cls, {1})\n'


lowerCAmelCase_   						=   '\ndef {0}(*args, **kwargs):\n    requires_backends({0}, {1})\n'



def      __UpperCAmelCase      (    __lowerCamelCase	)							->      List[Any]:
		lowercase__   :    str				=			_re_backend.findall(__lowerCamelCase	)
		if len(__lowerCamelCase	) == 0:
				return None

		return "_and_".join(__lowerCamelCase	)



def      __UpperCAmelCase      (    )							->      int:
		with open(os.path.join(__lowerCamelCase						,     '''__init__.py'''	)						,     '''r'''						,     encoding='''utf-8'''						,     newline='''\n'''	) as f:
				lowercase__   :    List[Any]				=			f.readlines()

		# Get to the point we do the actual imports for type checking
		lowercase__   :    str				=			0
		lowercase__   :    str				=			{}
		# Go through the end of the file
		while line_index < len(__lowerCamelCase	):
				# If the line contains is_backend_available, we grab all objects associated with the `else` block
				lowercase__   :    Any				=			find_backend(lines[line_index]	)
				if backend is not None:
						while not lines[line_index].startswith('''else:'''	):
								line_index += 1
						line_index += 1
						lowercase__   :    Tuple				=			[]
						# Until we unindent, add backend objects to the list
						while line_index < len(__lowerCamelCase	) and len(lines[line_index]	) > 1:
								lowercase__   :    List[Any]				=			lines[line_index]
								lowercase__   :    Any				=			_re_single_line_import.search(__lowerCamelCase	)
								if single_line_import_search is not None:
										objects.extend(single_line_import_search.groups()[0].split(''', '''	)	)
								elif line.startswith(''' ''' * 8	):
										objects.append(line[8:-2]	)
								line_index += 1

						if len(__lowerCamelCase	) > 0:
								lowercase__   :    List[Any]				=			objects
				else:
						line_index += 1

		return backend_specific_objects



def      __UpperCAmelCase      (    __lowerCamelCase						,     __lowerCamelCase	)							->      Union[str, Any]:
		if name.isupper():
				return DUMMY_CONSTANT.format(__lowerCamelCase	)
		elif name.islower():
				return DUMMY_FUNCTION.format(__lowerCamelCase						,     __lowerCamelCase	)
		else:
				return DUMMY_CLASS.format(__lowerCamelCase						,     __lowerCamelCase	)



def      __UpperCAmelCase      (    __lowerCamelCase=None	)							->      Tuple:
		if backend_specific_objects is None:
				lowercase__   :    List[str]				=			read_init()
		# For special correspondence backend to module name as used in the function requires_modulename
		lowercase__   :    Union[str, Any]				=			{}

		for backend, objects in backend_specific_objects.items():
				lowercase__   :    List[Any]				=			'''[''' + ''', '''.join(f"""\"{b}\"""" for b in backend.split('''_and_'''	)	) + ''']'''
				lowercase__   :    str				=			'''# This file is autogenerated by the command `make fix-copies`, do not edit.\n'''
				dummy_file += "from ..utils import DummyObject, requires_backends\n\n"
				dummy_file += "\n".join([create_dummy_object(__lowerCamelCase						,     __lowerCamelCase	) for o in objects]	)
				lowercase__   :    str				=			dummy_file

		return dummy_files



def      __UpperCAmelCase      (    __lowerCamelCase=False	)							->      Optional[Any]:
		lowercase__   :    Any				=			create_dummy_files()
		# For special correspondence backend to shortcut as used in utils/dummy_xxx_objects.py
		lowercase__   :    Any				=			{'''torch''': '''pt'''}

		# Locate actual dummy modules and read their content.
		lowercase__   :    int				=			os.path.join(__lowerCamelCase						,     '''utils'''	)
		lowercase__   :    List[Any]				=			{
		    backend: os.path.join(__lowerCamelCase						,     f"""dummy_{short_names.get(__lowerCamelCase						,     __lowerCamelCase	)}_objects.py"""	)
		    for backend in dummy_files.keys()
		}

		lowercase__   :    Tuple				=			{}
		for backend, file_path in dummy_file_paths.items():
				if os.path.isfile(__lowerCamelCase	):
						with open(__lowerCamelCase						,     '''r'''						,     encoding='''utf-8'''						,     newline='''\n'''	) as f:
								lowercase__   :    List[Any]				=			f.read()
				else:
						lowercase__   :    Any				=			''''''

		for backend in dummy_files.keys():
				if dummy_files[backend] != actual_dummies[backend]:
						if overwrite:
								print(
								    f"""Updating diffusers.utils.dummy_{short_names.get(__lowerCamelCase						,     __lowerCamelCase	)}_objects.py as the main """
								    '''__init__ has new objects.'''	)
								with open(dummy_file_paths[backend]						,     '''w'''						,     encoding='''utf-8'''						,     newline='''\n'''	) as f:
										f.write(dummy_files[backend]	)
						else:
								raise ValueError(
								    '''The main __init__ has objects that are not present in '''
								    f"""diffusers.utils.dummy_{short_names.get(__lowerCamelCase						,     __lowerCamelCase	)}_objects.py. Run `make fix-copies` """
								    '''to fix this.'''	)


if __name__ == "__main__":
							lowerCAmelCase_   						=   argparse.ArgumentParser()
							parser.add_argument('--fix_and_overwrite', action='store_true', help='Whether to fix inconsistencies.')
							lowerCAmelCase_   						=   parser.parse_args()

							check_dummies(args.fix_and_overwrite)







'''simple docstring'''




import math

import qiskit






def        _lowerCAmelCase			(  __snake_case  : int = 1 ,							__snake_case  : int = 1 ,							__snake_case  : int = 1			)     ->     qiskit.result.counts.Counts:
     if (
         isinstance(__snake_case ,							__snake_case			)
         or isinstance(__snake_case ,							__snake_case			)
         or isinstance(__snake_case ,							__snake_case			)
     ):
          raise TypeError('inputs must be integers.'			)

     if (input_a < 0) or (input_a < 0) or (carry_in < 0):
          raise ValueError('inputs must be positive.'			)

     if (
         (math.floor(__snake_case			) != input_a)
         or (math.floor(__snake_case			) != input_a)
         or (math.floor(__snake_case			) != carry_in)
     ):
          raise ValueError('inputs must be exact integers.'			)

     if (input_a > 2) or (input_a > 2) or (carry_in > 2):
          raise ValueError('inputs must be less or equal to 2.'			)

     # build registers
     __A						: int      =       qiskit.QuantumRegister(4 ,							'qr'			)
     __A						: Optional[int]      =       qiskit.ClassicalRegister(2 ,							'cr'			)
     # list the entries
     __A						: Union[str, Any]      =       [input_a, input_a, carry_in]

     __A						: Dict      =       qiskit.QuantumCircuit(__snake_case ,							__snake_case			)

     for i in range(0 ,							3			):
          if entry[i] == 2:
               quantum_circuit.h(__snake_case			)  # for hadamard entries
          elif entry[i] == 1:
               quantum_circuit.x(__snake_case			)  # for 1 entries
          elif entry[i] == 0:
               quantum_circuit.i(__snake_case			)  # for 0 entries

    # build the circuit
     quantum_circuit.ccx(0 ,							1 ,							3			)  # ccx = toffoli gate
     quantum_circuit.cx(0 ,							1			)
     quantum_circuit.ccx(1 ,							2 ,							3			)
     quantum_circuit.cx(1 ,							2			)
     quantum_circuit.cx(0 ,							1			)

     quantum_circuit.measure([2, 3] ,							__snake_case			)  # measure the last two qbits

     __A						: str      =       qiskit.Aer.get_backend('aer_simulator'			)
     __A						: Any      =       qiskit.execute(__snake_case ,							__snake_case ,							shots=10_00			)

     return job.result().get_counts(__snake_case			)


if __name__ == "__main__":
  print(f"""Total sum count for state is: {quantum_full_adder(1, 1, 1)}""")