def get_shard_list(length) -> list:
    """
    Function to generate shard_list for different partitions.
    """

    distributed_world_size = (
        _dist.get_world_size() if _dist.is_available() and _dist.is_initialized() else 1
    )
    shard_size = max(1, length // distributed_world_size)
    shard_list = list(range(0, length, shard_size))
    if len(shard_list) > distributed_world_size:
        shard_list = shard_list[:distributed_world_size] + [length]
    else:
        shard_list += [length] * (distributed_world_size + 1 - len(shard_list))

    return shard_list

    Function to generate shard_list for different partitions.
    
coremltools/optimize/torch/palettization/_utils.py