



"""simple docstring"""
from math import ceil





def  lowerCamelCase_						(UpperCamelCase__		:		Union[str, Any]     ,       UpperCamelCase__		:		Any							):
    _UpperCAmelCase							:  Tuple											=    list(range(0     ,       UpperCamelCase__							)							)

    _UpperCAmelCase							:  Any											=    [item for sublist in list(device_map.values()							) for item in sublist]

    # Duplicate check
    _UpperCAmelCase							:  str											=    []
    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
    _UpperCAmelCase							:  Union[str, Any]											=    [i for i in blocks if i not in device_map_blocks]
    _UpperCAmelCase							:  Optional[Any]											=    [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__		:		int     ,       UpperCamelCase__		:		Optional[int]							):
    _UpperCAmelCase							:  Tuple											=    list(range(UpperCamelCase__							)							)
    _UpperCAmelCase							:  Optional[Any]											=    int(ceil(n_layers / len(UpperCamelCase__							)							)							)
    _UpperCAmelCase							:  Optional[Any]											=    [layers[i : i + n_blocks] for i in range(0     ,       UpperCamelCase__     ,       UpperCamelCase__							)]

    return dict(zip(UpperCamelCase__     ,       UpperCamelCase__							)							)







"""simple docstring"""
def  lowerCamelCase_						(UpperCamelCase__		:		int     ,       UpperCamelCase__		:		int							):
    if a < 0 or b < 0:
        raise ValueError('''the value of both inputs must be positive'''							)
    _UpperCAmelCase							:  List[str]											=    str(bin(UpperCamelCase__							)							)[2:]  # remove the leading "0b"
    _UpperCAmelCase							:  str											=    str(bin(UpperCamelCase__							)							)[2:]
    _UpperCAmelCase							:  List[str]											=    max(len(UpperCamelCase__							)     ,       len(UpperCamelCase__							)							)
    return "0b" + "".join(
        str(int('''1''' in (char_a, char_b)							)							)
        for char_a, char_b in zip(a_binary.zfill(UpperCamelCase__							)     ,       b_binary.zfill(UpperCamelCase__							)							)							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()


