


import numpy as np
import PIL
import torch
import torchvision.transforms as T
import torchvision.transforms.functional as TF
from PIL import Image
def     UpperCAmelCase    (					_lowercase   :      int ,      _lowercase   :      Union[str, Any]=2_5_6  )	->   List[Any]:


	"""simple docstring"""




	lowerCAmelCase_			       = min(img.size  )

	if s < target_image_size:
		raise ValueError(F"""min dim for image {s} < {target_image_size}"""  )

	lowerCAmelCase_			       = target_image_size / s
	lowerCAmelCase_			       = (round(r * img.size[1]  ), round(r * img.size[0]  ))
	lowerCAmelCase_			       = TF.resize(_lowercase ,      _lowercase ,      interpolation=PIL.Image.LANCZOS  )
	lowerCAmelCase_			       = TF.center_crop(_lowercase ,      output_size=2 * [target_image_size]  )
	lowerCAmelCase_			       = torch.unsqueeze(T.ToTensor()(_lowercase  ) ,      0  )
	return img
def     UpperCAmelCase    (					_lowercase   :      str  )	->   Any:


	"""simple docstring"""




	lowerCAmelCase_			       = 2.0 * x - 1.0
	return x
def     UpperCAmelCase    (					_lowercase   :      Any ,      _lowercase   :      Optional[int]=True ,      _lowercase   :      str="RGB"  )	->   Tuple:


	"""simple docstring"""




	lowerCAmelCase_			       = x.detach().cpu()
	if process:
		lowerCAmelCase_			       = post_process_tensor(_lowercase  )
	lowerCAmelCase_			       = x.numpy()
	if process:
		lowerCAmelCase_			       = (2_5_5 * x).astype(np.uinta  )
	lowerCAmelCase_			       = Image.fromarray(_lowercase  )
	if not x.mode == mode:
		lowerCAmelCase_			       = x.convert(_lowercase  )
	return x
def     UpperCAmelCase    (					_lowercase   :      List[str]  )	->   Optional[int]:


	"""simple docstring"""




	lowerCAmelCase_			       = torch.clamp(_lowercase ,      -1.0 ,      1.0  )
	lowerCAmelCase_			       = (x + 1.0) / 2.0
	lowerCAmelCase_			       = x.permute(1 ,      2 ,      0  )
	return x





def     UpperCAmelCase    (					_lowercase   :      List[Any]  )	->   Any:


	"""simple docstring"""




	lowerCAmelCase_			       = post_process_tensor(x.squeeze()  )
	return x.permute(2 ,      0 ,      1  ).unsqueeze(0  )



"""simple docstring"""



import doctest

import projectq
from projectq.ops import H, Measure
def     UpperCAmelCase    (					_lowercase   :      projectq.cengines._main.MainEngine  )	->   int:


	"""simple docstring"""




	lowerCAmelCase_			       = quantum_engine.allocate_qubit()
	H | qubit
	Measure | qubit
	return int(_lowercase  )


if __name__ == "__main__":
		doctest.testmod()

		# initialises a new quantum backend
		lowercase_							 =       projectq.MainEngine()

		# Generate a list of 10 random numbers
		lowercase_							 =       [get_random_number(quantum_engine) for _ in range(10)]

		# Flushes the quantum engine from memory
		quantum_engine.flush()

		print('Random numbers', random_numbers_list)