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:						Union[str, Any]    	=       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    UpperCAmelCase__(						cls  ):



      """simple docstring"""





      return cls






def    UpperCAmelCase__(						lowerCamelCase_							,	lowerCamelCase_ = None							,	lowerCamelCase_ = None							,	lowerCamelCase_ = None							,	lowerCamelCase_ = None							,	):



   """simple docstring"""





   _snake_case              =      device
   _snake_case              =      shape[0]

   _snake_case              =      layout or torch.strided
   _snake_case              =      device or torch.device("cpu"  )

   if generator is not None:
      _snake_case              =      generator.device.type if not isinstance(lowerCamelCase_							,	lowerCamelCase_  ) else generator[0].device.type
      if gen_device_type != device.type and gen_device_type == "cpu":
         _snake_case              =      "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(lowerCamelCase_							,	lowerCamelCase_  ):
      _snake_case              =      (1,) + shape[1:]
      _snake_case              =      [
          torch.randn(lowerCamelCase_							,	generator=generator[i]							,	device=lowerCamelCase_							,	dtype=lowerCamelCase_							,	layout=lowerCamelCase_  )
          for i in range(lowerCamelCase_  )
      ]
      _snake_case              =      torch.cat(lowerCamelCase_							,	dim=0  ).to(lowerCamelCase_  )
   else:
      _snake_case              =      torch.randn(lowerCamelCase_							,	generator=lowerCamelCase_							,	device=lowerCamelCase_							,	dtype=lowerCamelCase_							,	layout=lowerCamelCase_  ).to(lowerCamelCase_  )

   return latents







def    UpperCAmelCase__(						lowerCamelCase_  ):



   """simple docstring"""





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


from math import gcd






def    UpperCAmelCase__(						lowerCamelCase_ = 12000  ):



			"""simple docstring"""





			_snake_case              =      0
			for d in range(max_d + 1  ):
						for n in range(d // 3 + 1							,	(d + 1) // 2  ):
									if gcd(lowerCamelCase_							,	lowerCamelCase_  ) == 1:
												fractions_number += 1
			return fractions_number


if __name__ == "__main__":
			print(F"{solution() = }")

