
"""simple docstring"""


from math import ceil






def  lowercase						(	lowerCAmelCase__	,lowerCAmelCase__						):
			lowerCamelCase_					=  list(range(0	,lowerCAmelCase__						)						)

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

			# Duplicate check
			lowerCamelCase_					=  []
			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
			lowerCamelCase_					=  [i for i in blocks if i not in device_map_blocks]
			lowerCamelCase_					=  [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						(	lowerCAmelCase__	,lowerCAmelCase__						):
			lowerCamelCase_					=  list(range(lowerCAmelCase__						)						)
			lowerCamelCase_					=  int(ceil(n_layers / len(lowerCAmelCase__						)						)						)
			lowerCamelCase_					=  [layers[i : i + n_blocks] for i in range(0	,lowerCAmelCase__	,lowerCAmelCase__						)]

			return dict(zip(lowerCAmelCase__	,lowerCAmelCase__						)						)









'''simple docstring'''


import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Audio, ClassLabel, Features
from .base import TaskTemplate





@dataclass(frozen=__magic_name__			)
class  __lowercase    (	__magic_name__			):
   _a    						=   field(default="""audio-classification"""							,				metadata={"""include_in_asdict_even_if_is_default""": True}			)
   _a    						=   Features({"""audio""": Audio()}			)
   _a    						=   Features({"""labels""": ClassLabel}			)
   _a    						=   "audio"
   _a    						=   "labels"







   def 		UpperCamelCase__      (						self   ,				UpperCamelCase   )					->     Dict:
     if self.label_column not in features:
       raise ValueError(f"Column {self.label_column} is not present in features."   )
     if not isinstance(features[self.label_column]   ,				UpperCamelCase   ):
       raise ValueError(f"Column {self.label_column} is not a ClassLabel."   )
     __a								=       copy.deepcopy(self   )
     __a								=       self.label_schema.copy()
     __a								=       features[self.label_column]
     __a								=       label_schema
     return task_template







   @property
   def 		UpperCamelCase__      (						self   )					->     Dict[str, str]:
     return {
         self.audio_column: "audio",
         self.label_column: "labels",
     }



