def _check_rank_and_size_consistent_with_horovod(petastorm_reader_kwargs):
    """Check whether the ``cur_shard`` and ``shard_count`` args are consistent with horovod environment variables.

    If not consistent with horovod environment variables, log warning message and return ``False``.
    If there're no related horovod environment variable set, return ``True``.
    """
    hvd_rank, hvd_size = _get_horovod_rank_and_size()
    cur_shard = petastorm_reader_kwargs.get('cur_shard')
    shard_count = petastorm_reader_kwargs.get('shard_count')

    if hvd_rank is not None and hvd_size is not None:
        if cur_shard != hvd_rank or shard_count != hvd_size:
            logger.warning(
                'The petastorm reader arguments cur_shard(%d) and '
                'shard_count(%d) is not consistent with horovod '
                'environments hvd_rank(%d) and hvd_size(%d), If you want '
                'each horovod worker train on one corresponding shard data, '
                'you should set argument `cur_shard` to be `hvd.rank()` '
                'and argument `shard_count` to be `hvd.size()`.',
                cur_shard, shard_count, hvd_rank, hvd_size)
            return False
    return True
Check whether the ``cur_shard`` and ``shard_count`` args are consistent with horovod environment variables.

    If not consistent with horovod environment variables, log warning message and return ``False``.
    If there're no related horovod environment variable set, return ``True``.
    
petastorm/spark/spark_dataset_converter.py