

import enum
import inspect
import warnings
from functools import wraps
from typing import Callable, Optional

from .logging import get_logger


a				:							List[str]					=			set()
a				:							List[Any]					=			get_logger(__name__)






def    _UpperCAmelCase	(   __lowerCamelCase = None       )		->Any:


 '''simple docstring'''

 def decorator(__lowerCamelCase       ):
  global _emitted_deprecation_warnings

  if inspect.isclass(__lowerCamelCase       ):
   snake_case   : Union[str, Any]	  =      deprecated_class_or_function.__init__
   snake_case   : Optional[Any]	  =      deprecated_class_or_function.__name__
  else:
   snake_case   : Optional[int]	  =      deprecated_class_or_function
   snake_case   : Optional[Any]	  =      deprecated_function.__name__
   # Support deprecating __init__ class method: class name instead
   snake_case   : List[str]	  =      name if name != '''__init__''' else deprecated_function.__qualname__.split('''.'''       )[-2]

  snake_case   : Optional[int]	  =      (
      f'''{name} is deprecated and will be removed in the next major version of datasets.''' + f''' {help_message}'''
      if help_message
      else ''''''
  )

  @wraps(__lowerCamelCase       )
  def wrapper(*__lowerCamelCase ,     **__lowerCamelCase       ):
   snake_case   : Optional[Any]	  =      hash(__lowerCamelCase       )
   if func_hash not in _emitted_deprecation_warnings:
    warnings.warn(__lowerCamelCase ,     category=__lowerCamelCase ,     stacklevel=2       )
    _emitted_deprecation_warnings.add(__lowerCamelCase       )
   return deprecated_function(*__lowerCamelCase ,     **__lowerCamelCase       )

  snake_case   : Optional[int]	  =      '''deprecated'''

  if inspect.isclass(__lowerCamelCase       ):
   snake_case   : int	  =      wrapper
   return deprecated_class_or_function
  else:
   return wrapper

 return decorator

class      lowerCamelCase	(  enum.EnumMeta     ):

       def __getattribute__(			cls	,						a__					):






        '''simple docstring'''






        snake_case   : str	  =      super().__getattribute__(a__					)
        if isinstance(a__	,						enum.Enum					) and obj._on_access:
         obj._on_access()
        return obj

       def __getitem__(			cls	,						a__					):






        '''simple docstring'''






        snake_case   : List[Any]	  =      super().__getitem__(a__					)
        if member._on_access:
         member._on_access()
        return member



       def __call__(			cls	,						a__	,						a__=None	,						*, a__=None	,						a__=None	,						a__=None	,						a__=1					):






        '''simple docstring'''






        snake_case   : Any	  =      super().__call__(a__	,						a__	,						module=a__	,						qualname=a__	,						type=a__	,						start=a__					)
        if isinstance(a__	,						enum.Enum					) and obj._on_access:
         obj._on_access()
        return obj







class      lowerCamelCase	(  enum.Enum,			metaclass=SCREAMING_SNAKE_CASE     ):

       def __new__(			cls	,						a__					):






        '''simple docstring'''






        snake_case   : List[Any]	  =      object.__new__(cls					)
        snake_case   : int	  =      value
        snake_case   : List[Any]	  =      member.deprecate
        return member

       @property
       def 				UpperCAmelCase				(			self					):






        '''simple docstring'''






        return ""



       def 				UpperCAmelCase				(			self					):






        '''simple docstring'''






        snake_case   : str	  =      f''' {self.help_message}''' if self.help_message else ''''''
        warnings.warn(
            f'''\'{self.__objclass__.__name__}\' is deprecated and will be removed in the next major version of datasets.'''
            + help_message	,						a__	,						stacklevel=3	,						)










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

a				:							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       )		->str:


   '''simple docstring'''
   return cls






def    _UpperCAmelCase	(   __lowerCamelCase ,     __lowerCamelCase = None ,     __lowerCamelCase = None ,     __lowerCamelCase = None ,     __lowerCamelCase = None ,     )		->Union[str, Any]:


 '''simple docstring'''
 snake_case   : Union[str, Any]	  =      device
 snake_case   : Any	  =      shape[0]

 snake_case   : Any	  =      layout or torch.strided
 snake_case   : Union[str, Any]	  =      device or torch.device('''cpu'''       )

 if generator is not None:
  snake_case   : Any	  =      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   : Optional[int]	  =      '''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   : Tuple	  =      (1,) + shape[1:]
  snake_case   : List[Any]	  =      [
      torch.randn(__lowerCamelCase ,     generator=generator[i] ,     device=__lowerCamelCase ,     dtype=__lowerCamelCase ,     layout=__lowerCamelCase       )
      for i in range(__lowerCamelCase       )
  ]
  snake_case   : int	  =      torch.cat(__lowerCamelCase ,     dim=0       ).to(__lowerCamelCase       )
 else:
  snake_case   : Union[str, Any]	  =      torch.randn(__lowerCamelCase ,     generator=__lowerCamelCase ,     device=__lowerCamelCase ,     dtype=__lowerCamelCase ,     layout=__lowerCamelCase       ).to(__lowerCamelCase       )

 return latents






def    _UpperCAmelCase	(   __lowerCamelCase       )		->Tuple:


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






