def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False):
    "Test model with multiple gpus.\n\n    This method tests model with multiple gpus and collects the results\n    under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'\n    it encodes results to gpu tensors and use gpu communication for results\n    collection. On cpu mode it saves the results on different gpus to 'tmpdir'\n    and collects them by the rank 0 worker.\n\n    Args:\n        model (nn.Module): Model to be tested.\n        data_loader (nn.Dataloader): Pytorch data loader.\n        tmpdir (str): Path of directory to save the temporary results from\n            different gpus under cpu mode.\n        gpu_collect (bool): Option to use either gpu or cpu to collect results.\n\n    Returns:\n        list: The prediction results.\n    "
    model.eval()
    results = []
    dataset = data_loader.dataset
    (rank, world_size) = get_dist_info()
    if (rank == 0):
        prog_bar = mmcv.ProgressBar(len(dataset))
    time.sleep(2)
    for (i, data) in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=True, **data)
            if isinstance(result[0], tuple):
                result = [(bbox_results, encode_mask_results(mask_results)) for (bbox_results, mask_results) in result]
        results.extend(result)
        if (rank == 0):
            batch_size = len(result)
            for _ in range((batch_size * world_size)):
                prog_bar.update()
    if gpu_collect:
        results = collect_results_gpu(results, len(dataset))
    else:
        results = collect_results_cpu(results, len(dataset), tmpdir)
    return results
Test model with multiple gpus.

This method tests model with multiple gpus and collects the results
under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'
it encodes results to gpu tensors and use gpu communication for results
collection. On cpu mode it saves the results on different gpus to 'tmpdir'
and collects them by the rank 0 worker.

Args:
    model (nn.Module): Model to be tested.
    data_loader (nn.Dataloader): Pytorch data loader.
    tmpdir (str): Path of directory to save the temporary results from
        different gpus under cpu mode.
    gpu_collect (bool): Option to use either gpu or cpu to collect results.

Returns:
    list: The prediction results.
def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False):
    "Test model with multiple gpus.\n\n    This method tests model with multiple gpus and collects the results\n    under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'\n    it encodes results to gpu tensors and use gpu communication for results\n    collection. On cpu mode it saves the results on different gpus to 'tmpdir'\n    and collects them by the rank 0 worker.\n\n    Args:\n        model (nn.Module): Model to be tested.\n        data_loader (nn.Dataloader): Pytorch data loader.\n        tmpdir (str): Path of directory to save the temporary results from\n            different gpus under cpu mode.\n        gpu_collect (bool): Option to use either gpu or cpu to collect results.\n\n    Returns:\n        list: The prediction results.\n    "
    model.eval()
    results = []
    dataset = data_loader.dataset
    (rank, world_size) = get_dist_info()
    if (rank == 0):
        prog_bar = mmcv.ProgressBar(len(dataset))
    time.sleep(2)
    for (i, data) in enumerate(data_loader):
        with torch.no_grad():
            result = model(return_loss=False, rescale=True, **data)
            if isinstance(result[0], tuple):
                result = [(bbox_results, encode_mask_results(mask_results)) for (bbox_results, mask_results) in result]
        results.extend(result)
        if (rank == 0):
            batch_size = len(result)
            for _ in range((batch_size * world_size)):
                prog_bar.update()
    if gpu_collect:
        results = collect_results_gpu(results, len(dataset))
    else:
        results = collect_results_cpu(results, len(dataset), tmpdir)
    return results