
from typing import List, Optional, Tuple, Union

from . import logging
from .import_utils import is_torch_available, is_torch_version


if is_torch_available():
					import torch

_SCREAMING_SNAKE_CASE     :   Dict							 =      logging.get_logger(__name__)  # pylint: disable=invalid-name

try:
					from torch._dynamo import allow_in_graph as maybe_allow_in_graph
except (ImportError, ModuleNotFoundError):

					def 					SCREAMING_SNAKE_CASE  (   cls			:    Dict							)			->							Union[str, Any]:

									"""simple docstring"""







									return cls

def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    Union[Tuple, List]				,    __UpperCamelCase			:    Optional[Union[List["torch.Generator"], "torch.Generator"]] = None				,    __UpperCamelCase			:    Optional["torch.device"] = None				,    __UpperCamelCase			:    Optional["torch.dtype"] = None				,    __UpperCamelCase			:    Optional["torch.layout"] = None				,    )			->							List[str]:

				"""simple docstring"""







				A__	:						Optional[Any]								=				device
				A__	:						Any								=				shape[0]

				A__	:						List[str]								=				layout or torch.strided
				A__	:						List[Any]								=				device or torch.device('''cpu'''							)

				if generator is not None:
								A__	:						Dict								=				generator.device.type if not isinstance(__UpperCamelCase				,    __UpperCamelCase							) else generator[0].device.type
								if gen_device_type != device.type and gen_device_type == "cpu":
												A__	:						List[str]								=				'''cpu'''
												if device != "mps":
																logger.info(
																    F"The passed generator was created on 'cpu' even though a tensor on {device} was expected."
																    F" Tensors will be created on 'cpu' and then moved to {device}. Note that one can probably"
																    F" slighly speed up this function by passing a generator that was created on the {device} device."							)
								elif gen_device_type != device.type and gen_device_type == "cuda":
												raise ValueError(F"Cannot generate a {device} tensor from a generator of type {gen_device_type}."							)

				if isinstance(__UpperCamelCase				,    __UpperCamelCase							):
								A__	:						Any								=				(1,) + shape[1:]
								A__	:						List[Any]								=				[
								    torch.randn(__UpperCamelCase				,    generator=generator[i]				,    device=__UpperCamelCase				,    dtype=__UpperCamelCase				,    layout=__UpperCamelCase							)
								    for i in range(__UpperCamelCase							)
								]
								A__	:						Optional[int]								=				torch.cat(__UpperCamelCase				,    dim=0							).to(__UpperCamelCase							)
				else:
								A__	:						List[str]								=				torch.randn(__UpperCamelCase				,    generator=__UpperCamelCase				,    device=__UpperCamelCase				,    dtype=__UpperCamelCase				,    layout=__UpperCamelCase							).to(__UpperCamelCase							)

				return latents



def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    Optional[int]							)			->							List[str]:

				"""simple docstring"""







				if is_torch_version('''<'''				,    '''2.0.0'''							) or not hasattr(__UpperCamelCase				,    '''_dynamo'''							):
								return False
				return isinstance(__UpperCamelCase				,    torch._dynamo.eval_frame.OptimizedModule							)

def 					SCREAMING_SNAKE_CASE  (   __UpperCamelCase			:    Dict				,    __UpperCamelCase			:    Dict							)			->							List[Any]:

				"""simple docstring"""







				if len(str(__UpperCamelCase							)							) == 1 or len(str(__UpperCamelCase							)							) == 1:
								return a * b

				A__	:						List[str]								=				max(len(str(__UpperCamelCase							)							)				,    len(str(__UpperCamelCase							)							)							)
				A__	:						Any								=				ma // 2

				A__							,				A__	:						Union[str, Any]								=				divmod(__UpperCamelCase				,    10**ma							)
				A__							,				A__	:						Tuple								=				divmod(__UpperCamelCase				,    10**ma							)

				A__	:						Optional[int]								=				karatsuba(__UpperCamelCase				,    __UpperCamelCase							)
				A__	:						Tuple								=				karatsuba((aa + aa)				,    (ba + ba)							)
				A__	:						Optional[int]								=				karatsuba(__UpperCamelCase				,    __UpperCamelCase							)

				return (z * 10 ** (2 * ma)) + ((y - z - x) * 10 ** (ma)) + (x)

def 					SCREAMING_SNAKE_CASE  (   )			->							Dict:

				"""simple docstring"""







				print(karatsuba(1_54_63				,    2_34_89							)							)


if __name__ == "__main__":
					main()