




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

_lowerCAmelCase  :				str						=				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   lowerCAmelCase						(						cls							:				str		):




   """simple docstring"""







   return cls



def   lowerCAmelCase						(						_lowerCAmelCase							:				Union[Tuple, List]  ,							_lowerCAmelCase							:				Optional[Union[List["torch.Generator"], "torch.Generator"]] = None  ,							_lowerCAmelCase							:				Optional["torch.device"] = None  ,							_lowerCAmelCase							:				Optional["torch.dtype"] = None  ,							_lowerCAmelCase							:				Optional["torch.layout"] = None  ,							):




 """simple docstring"""







 UpperCAmelCase__								=  device
 UpperCAmelCase__								=  shape[0]

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

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

 return latents



def   lowerCAmelCase						(						_lowerCAmelCase							:				List[str]		):




 """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 collections import defaultdict



def   lowerCAmelCase						(						_lowerCAmelCase							:				int = 5		):




 """simple docstring"""







 UpperCAmelCase__								=  defaultdict(_lowerCAmelCase		)
 UpperCAmelCase__								=  0

 while True:
  UpperCAmelCase__								=  get_digits(_lowerCAmelCase		)
  freqs[digits].append(_lowerCAmelCase		)

  if len(freqs[digits]		) == max_base:
   UpperCAmelCase__								=  freqs[digits][0] ** 3
   return base

  num += 1



def   lowerCAmelCase						(						_lowerCAmelCase							:				int		):




 """simple docstring"""







 return "".join(sorted(str(num**3		)		)		)


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





