def _get_horovod_rank_and_size():
    """Get rank and size from environment, return (rank, size), if failed, return (``None``, ``None``)"""
    rank_env = ['HOROVOD_RANK', 'OMPI_COMM_WORLD_RANK', 'PMI_RANK']
    size_env = ['HOROVOD_SIZE', 'OMPI_COMM_WORLD_SIZE', 'PMI_SIZE']

    for rank_var, size_var in zip(rank_env, size_env):
        rank = os.environ.get(rank_var)
        size = os.environ.get(size_var)
        if rank is not None and size is not None:
            return int(rank), int(size)
        elif rank is not None or size is not None:
            return None, None

    return None, None
Get rank and size from environment, return (rank, size), if failed, return (``None``, ``None``)
petastorm/spark/spark_dataset_converter.py