import multiprocessing


def get_max_workers(data=None) -> int:
    """Returns int to pass to max_workers based on len of `data` if available or `cpu_count()`"""
    if data is not None and hasattr(data, "__len__"):
        return min(multiprocessing.cpu_count(), len(data))
    else:
        return multiprocessing.cpu_count()