code: def geolocalization_test(
      cfg: AttrDict, layer_name: str = "heads", topk: int = 1
  ):
      output_dir = get_checkpoint_folder(cfg)
      logging.info(f"Output dir: {output_dir} ...")
  
      ############################################################################
      # Step 1: Load the mapping file and partition it
      # Also load the test images and targets (latitude/longitude)
      # lastly, load the model predictions
      logging.info(
          f"Loading the label partitioning file: {cfg.GEO_LOCALIZATION.TRAIN_LABEL_MAPPING}"
      )
      partitioning = Partitioning(
          cfg.GEO_LOCALIZATION.TRAIN_LABEL_MAPPING
      )
  
      data_files, label_files = get_data_files("TEST", cfg.DATA)
      test_image_paths = load_file(data_files[0])
      target_lat_long = load_file(label_files[0])
      logging.info(
          f"Loaded val image paths: {test_image_paths.shape}, "
          f"ground truth latitude/longitude: {target_lat_long.shape}"
      )
  
      prediction_image_indices_filepath = (
          f"{output_dir}/rank0_test_{layer_name}_inds.npy"
      )
      predictions_filepath = (
          f"{output_dir}/rank0_test_{layer_name}_predictions.npy"
      )
      predictions = load_file(predictions_filepath)
      predictions_inds = load_file(prediction_image_indices_filepath)
      logging.info(
          f"Loaded predictions: {predictions.shape}, inds: {predictions_inds.shape}"
      )
  
      ############################################################################
      # Step 2: Convert the predicted classes to latitude/longitude and compute
      # accuracy at different km thresholds.
      gt_latitudes, gt_longitudes, predicted_lats, predicted_longs = (
          [],
          [],
          [],
          [],
      )
      output_metadata = {}
      num_images = len(test_image_paths)
      num_images = min(num_images, len(predictions))
      for idx in range(num_images):
          img_index = predictions_inds[idx]
          inp_img_path = test_image_paths[img_index]
          gt_latitude = float(target_lat_long[img_index][0])
          gt_longitude = float(target_lat_long[img_index][1])
          pred_cls = int(predictions[idx][:topk])
          pred_lat, pred_long = partitioning.get_lat_lng(pred_cls)
          output_metadata[inp_img_path] = {
              "target_lat": gt_latitude,
              "target_long": gt_longitude,
              "pred_lat": pred_lat,
              "pred_long": pred_long,
              "pred_cls": pred_cls,
          }
          gt_latitudes.append(gt_latitude)
          gt_longitudes.append(gt_longitude)
          predicted_lats.append(pred_lat)
          predicted_longs.append(pred_long)
  
      predicted_lats = torch.tensor(predicted_lats, dtype=torch.float)
      predicted_longs = torch.tensor(predicted_longs, dtype=torch.float)
      gt_latitudes = torch.tensor(gt_latitudes, dtype=torch.float)
      gt_longitudes = torch.tensor(gt_longitudes, dtype=torch.float)
      distances = vectorized_gc_distance(
          predicted_lats,
          predicted_longs,
          gt_latitudes,
          gt_longitudes,
      )
  
      # accuracy for all distances (in km)
      acc_dict = gcd_threshold_eval(
          distances, thresholds=cfg.GEO_LOCALIZATION.ACC_KM_THRESHOLDS
      )
      gcd_dict = {}
      for gcd_thres, acc in acc_dict.items():
          gcd_dict[f"{gcd_thres}"] = round(acc * 100.0, 4)
      logging.info(f"acc dist in percentage: {gcd_dict}")
      save_file(
          output_metadata,
          f"{output_dir}/output_metadata_predictions.json",
          append_to_json=False,
      )
      save_file(
          gcd_dict,
          f"{output_dir}/metrics.json",
          append_to_json=False,
      )
      return output_metadata, acc_dict
  
imports: import logging
  import os
  import sys
  from argparse import Namespace
  from typing import Any, List
  import pandas
  import torch
  from hydra.experimental import compose, initialize_config_module
  from iopath.common.file_io import g_pathmgr
  from vissl.config import AttrDict
  from vissl.data.dataset_catalog import get_data_files
  from vissl.hooks import default_hook_generator
  from vissl.utils.checkpoint import get_checkpoint_folder
  from vissl.utils.distributed_launcher import launch_distributed
  from vissl.utils.env import set_env_vars
  from vissl.utils.hydra_config import convert_to_attrdict, is_hydra_available, print_cfg
  from vissl.utils.io import load_file, save_file
  from vissl.utils.logger import setup_logging, shutdown_logging
label_desc: Use image node_id 3 for calling a global function with example usage: geolocalization_test(cfg, layer_name, topk) and returns: output_metadata,  acc_dict