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

from .logging import get_logger


__a  :					str          =  set()
__a  :					Tuple          =  get_logger(__name__)





def     UpperCAmelCase						(   lowercase = None							):







				"""simple docstring"""



				def decorator(lowercase							):
								global _emitted_deprecation_warnings

								if inspect.isclass(lowercase							):
												__lowercase			      =							deprecated_class_or_function.__init__
												__lowercase			      =							deprecated_class_or_function.__name__
								else:
												__lowercase			      =							deprecated_class_or_function
												__lowercase			      =							deprecated_function.__name__
												# Support deprecating __init__ class method: class name instead
												__lowercase			      =							name if name != '''__init__''' else deprecated_function.__qualname__.split('''.'''							)[-2]

								__lowercase			      =							(
								    F"{name} is deprecated and will be removed in the next major version of datasets." + F" {help_message}"
								    if help_message
								    else ''''''
								)

								@wraps(lowercase							)
								def wrapper(*lowercase							,      **lowercase							):
												__lowercase			      =							hash(lowercase							)
												if func_hash not in _emitted_deprecation_warnings:
																warnings.warn(lowercase							,      category=lowercase							,      stacklevel=2							)
																_emitted_deprecation_warnings.add(lowercase							)
												return deprecated_function(*lowercase							,      **lowercase							)

								__lowercase			      =							'''deprecated'''

								if inspect.isclass(lowercase							):
												__lowercase			      =							wrapper
												return deprecated_class_or_function
								else:
												return wrapper

				return decorator




class        _UpperCamelCase				(						enum.EnumMeta			):


			"""simple docstring"""






			def __getattribute__(       cls				,       lowerCAmelCase__						)					-> List[Any]:

							'''simple docstring'''


							__lowercase			      =							super().__getattribute__(lowerCAmelCase__						)
							if isinstance(lowerCAmelCase__				,       enum.Enum						) and obj._on_access:
											obj._on_access()
							return obj





			def __getitem__(       cls				,       lowerCAmelCase__						)					-> List[str]:

							'''simple docstring'''


							__lowercase			      =							super().__getitem__(lowerCAmelCase__						)
							if member._on_access:
											member._on_access()
							return member





			def __call__(       cls				,       lowerCAmelCase__				,       lowerCAmelCase__=None				,       *, lowerCAmelCase__=None				,       lowerCAmelCase__=None				,       lowerCAmelCase__=None				,       lowerCAmelCase__=1						)					-> Optional[Any]:

							'''simple docstring'''


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




class        _UpperCamelCase				(						enum.Enum						,metaclass=_UpperCAmelCase			):


			"""simple docstring"""






			def __new__(       cls				,       lowerCAmelCase__						)					-> Union[str, Any]:

							'''simple docstring'''


							__lowercase			      =							object.__new__(cls						)
							__lowercase			      =							value
							__lowercase			      =							member.deprecate
							return member





			@property
			def 	_SCREAMING_SNAKE_CASE      (       self						)					-> Optional[int]:

							'''simple docstring'''


							return ""





			def 	_SCREAMING_SNAKE_CASE      (       self						)					-> Optional[Any]:

							'''simple docstring'''


							__lowercase			      =							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				,       lowerCAmelCase__				,       stacklevel=3				,       )
from typing import TypeVar

from .arrow_dataset import Dataset, _split_by_node_map_style_dataset
from .iterable_dataset import IterableDataset, _split_by_node_iterable_dataset


__a  :					Union[str, Any]          =  TypeVar("""DatasetType""", Dataset, IterableDataset)





def     UpperCAmelCase						(   lowercase							,      lowercase							,      lowercase							):







				"""simple docstring"""



				if isinstance(lowercase							,      lowercase							):
								return _split_by_node_map_style_dataset(lowercase							,      rank=lowercase							,      world_size=lowercase							)
				else:
								return _split_by_node_iterable_dataset(lowercase							,      rank=lowercase							,      world_size=lowercase							)