



from math import ceil



def 		lowerCAmelCase__     (       UpperCamelCase_					:							str			,							UpperCamelCase_					:							List[str]						)->	Optional[int]:
    A__					=       list(range(0			,							UpperCamelCase_						)						)

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

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

    if len(UpperCamelCase_						) != 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(UpperCamelCase_						)						)
    if len(UpperCamelCase_						) != 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(UpperCamelCase_						)						)
    if len(UpperCamelCase_						) != 0:
        raise ValueError(
            '''The device_map contains more attention blocks than this model has. Remove these from the device_map:'''
            + str(UpperCamelCase_						)						)



def 		lowerCAmelCase__     (       UpperCamelCase_					:							Optional[Any]			,							UpperCamelCase_					:							Any						)->	Optional[Any]:
    A__					=       list(range(UpperCamelCase_						)						)
    A__					=       int(ceil(n_layers / len(UpperCamelCase_						)						)						)
    A__					=       [layers[i : i + n_blocks] for i in range(0			,							UpperCamelCase_			,							UpperCamelCase_						)]

    return dict(zip(UpperCamelCase_			,							UpperCamelCase_						)						)





from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase    	=		{
    "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"],
    "feature_extraction_mctct": ["MCTCTFeatureExtractor"],
    "processing_mctct": ["MCTCTProcessor"],
}


try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _lowercase    	=		[
       "MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
       "MCTCTForCTC",
       "MCTCTModel",
       "MCTCTPreTrainedModel",
   ]


if TYPE_CHECKING:
   from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
   from .feature_extraction_mctct import MCTCTFeatureExtractor
   from .processing_mctct import MCTCTProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
   import sys

   _lowercase    	=		_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
