



from math import ceil






def 	__lowercase   ( a__							,   a__   )				-> Tuple:
							__SCREAMING_SNAKE_CASE									=					list(range(0							,   __lowerCamelCase   )   )

							__SCREAMING_SNAKE_CASE									=					[item for sublist in list(device_map.values()   ) for item in sublist]

							# Duplicate check
							__SCREAMING_SNAKE_CASE									=					[]
							for i in device_map_blocks:
														if device_map_blocks.count(__lowerCamelCase   ) > 1 and i not in duplicate_blocks:
																					duplicate_blocks.append(__lowerCamelCase   )
														# Missing blocks
							__SCREAMING_SNAKE_CASE									=					[i for i in blocks if i not in device_map_blocks]
							__SCREAMING_SNAKE_CASE									=					[i for i in device_map_blocks if i not in blocks]

							if len(__lowerCamelCase   ) != 0:
														raise ValueError(
														    'Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device.'
														    ' These attention blocks were specified more than once: ' + str(__lowerCamelCase   )   )
							if len(__lowerCamelCase   ) != 0:
														raise ValueError(
														    'There are attention blocks for this model that are not specified in the device_map. Add these attention '
														    'blocks to a device on the device_map: ' + str(__lowerCamelCase   )   )
							if len(__lowerCamelCase   ) != 0:
														raise ValueError(
														    'The device_map contains more attention blocks than this model has. Remove these from the device_map:'
														    + str(__lowerCamelCase   )   )






def 	__lowercase   ( a__							,   a__   )				-> Tuple:
							__SCREAMING_SNAKE_CASE									=					list(range(__lowerCamelCase   )   )
							__SCREAMING_SNAKE_CASE									=					int(ceil(n_layers / len(__lowerCamelCase   )   )   )
							__SCREAMING_SNAKE_CASE									=					[layers[i : i + n_blocks] for i in range(0							,   __lowerCamelCase							,   __lowerCamelCase   )]

							return dict(zip(__lowerCamelCase							,   __lowerCamelCase   )   )














from abc import ABC, abstractmethod
from typing import Optional, Union

from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit
from ..utils.typing import NestedDataStructureLike, PathLike
class     a    ( lowercase__   ):



      """simple docstring"""


      def __init__(      self					:			Any		,      __lowercase					:			Optional[NestedDataStructureLike[PathLike]] = None		,      __lowercase					:			Optional[NamedSplit] = None		,      __lowercase					:			Optional[Features] = None		,      __lowercase					:			str = None		,      __lowercase					:			bool = False		,      __lowercase					:			bool = False		,      __lowercase					:			Optional[int] = None		,      **__lowercase					:			List[str]		,      )							->      Tuple:
        __UpperCAmelCase							:	Any           =  path_or_paths
        __UpperCAmelCase							:	Dict           =  split if split or isinstance(__lowercase		,      __lowercase					) else """train"""
        __UpperCAmelCase							:	Optional[int]           =  features
        __UpperCAmelCase							:	str           =  cache_dir
        __UpperCAmelCase							:	str           =  keep_in_memory
        __UpperCAmelCase							:	Optional[int]           =  streaming
        __UpperCAmelCase							:	Dict           =  num_proc
        __UpperCAmelCase							:	Tuple           =  kwargs




      @abstractmethod
      def 	UpperCAmelCase      (      self					:			List[Any]					)							->      Union[Dataset, DatasetDict, IterableDataset, IterableDatasetDict]:
        pass


class     a    ( lowercase__   ):



      """simple docstring"""


      def __init__(      self					:			List[str]		,      __lowercase					:			Optional[Features] = None		,      __lowercase					:			str = None		,      __lowercase					:			bool = False		,      __lowercase					:			bool = False		,      __lowercase					:			Optional[int] = None		,      **__lowercase					:			Optional[Any]		,      )							->      Optional[int]:
        __UpperCAmelCase							:	Optional[Any]           =  features
        __UpperCAmelCase							:	str           =  cache_dir
        __UpperCAmelCase							:	Optional[int]           =  keep_in_memory
        __UpperCAmelCase							:	Dict           =  streaming
        __UpperCAmelCase							:	Optional[Any]           =  num_proc
        __UpperCAmelCase							:	Union[str, Any]           =  kwargs




      @abstractmethod
      def 	UpperCAmelCase      (      self					:			List[str]					)							->      Union[Dataset, IterableDataset]:
        pass


