def METHOD_NAME(shard: int, all_images: Set[str], image_dir: str, base_url: str):
    """Download full GLDv2 dataset, only keep images that are included in the federated gld v2 dataset.
    Args:
      shard: The shard of the GLDv2 dataset.
      all_images: A set which contains all images included in the federated GLD
        dataset.
      image_dir: The directory to keep all filtered images.
      base_url: The base url for downloading GLD v2 dataset images.
    Raises:
      IOError: when failed to download checksum.
    """
    shard_str = "%03d" % shard
    images_tar_url = "%s/train/images_%s.tar" % (base_url, shard_str)
    # images_md5_url = '%s/md5sum/train/md5.images_%s.txt' % (base_url, shard_str)
    with tempfile.TemporaryDirectory() as tmp_dir:
        logger = logging.getLogger(LOGGER)
        # logging.info('Start to download checksum for shard %s', shard_str)
        # get_file(
        #     'images_md5_%s.txt' % shard_str,
        #     origin=images_md5_url,
        #     cache_dir=tmp_dir)
        # logging.info('Downloaded checksum for shard %s successfully.', shard_str)
        logging.info("Start to download data for shard %s", shard_str)
        get_file(
            "images_%s.tar" % shard_str,
            origin=images_tar_url,
            extract=True,
            cache_dir=tmp_dir,
        )
        logging.info("Data for shard %s was downloaded successfully.", shard_str)
        count = 0
        for root, _, files in os.walk(tmp_dir):
            for filename in files:
                name, extension = os.path.splitext(filename)
                if extension == ".jpg" and name in all_images:
                    count += 1
                    shutil.copyfile(
                        os.path.join(root, filename), os.path.join(image_dir, filename)
                    )
        logging.info("Moved %d images from shard %s to %s", count, shard_str, image_dir)