code: def load_cc_face_crops_labels_images_preds_metadata(
      input_data, confidence_threshold=0.0
  ):
      # load the image paths
      image_paths = load_file(input_data["image_paths"])
      print(f"Number of image_paths: {image_paths.shape}\n")
  
      # load the predictions
      predictions = load_file(input_data["label_predictions"])
      print(f"Number of predictions: {predictions.shape}\n")
  
      # load the indices
      indices = load_file(input_data["pred_img_indices"])
      print(f"Number of indices: {indices.shape}\n")
  
      # load the confidence scores if provided
      has_confidence_scores = False
      if "label_predictions_scores" in input_data:
          confidence_scores = load_file(
              input_data["label_predictions_scores"]
          )
          filtered_confidence_scores, out_predictions = [], []
          for img_idx in range(len(predictions)):
              img_predictions, img_scores = [], []
              for pred_idx in predictions[img_idx]:
                  if (
                      confidence_scores[img_idx][pred_idx]
                      >= confidence_threshold
                  ):
                      img_predictions.append(pred_idx)
                      img_scores.append(
                          str(
                              round(
                                  confidence_scores[img_idx][pred_idx],
                                  5,
                              )
                          )
                      )
              filtered_confidence_scores.append(img_scores)
              out_predictions.append(img_predictions)
          has_confidence_scores = True
          predictions = out_predictions
          print(
              f"Confidence scores: {len(filtered_confidence_scores)}\n"
          )
  
      # load the metadata
      metadata = load_file(input_data["metadata"])
      if isinstance(metadata, list):
          print(f"metadata: {len(metadata)}")
          print(f"metadata keys: {metadata[0].keys()}")
      else:
          print(f"metadata: {list(metadata.values())[0].keys()}")
  
      # load the label id map
      label_to_id = load_file(input_data["label_to_id_map"])
      id_to_label = {value: key for key, value in label_to_id.items()}
      print("Loaded label_to_id and generated id_to_label map")
  
      cc_map = {}
      for item in metadata:
          path = item["img_path"]
          path = ("_").join(
              ("/").join(path.split("/")[-3:]).split("_")[:-1]
          )
          gender = item["gender"].lower()
          age = get_cc_age_bucket(item["age"])
          skintone = get_cc_skintone_name(item["skin-type"])
          cc_map[path] = {
              "gender": gender,
              "age": age,
              "skintone": f"{skintone}",
              "gender_skintone": f"{gender}_{skintone}",
              "path": path,
          }
      # now we filter further based on the image paths actually present in the data
      # and we enter the information about the prediction
      filtered_cc_map = {}
      for item in range(len(indices)):
          idx = indices[item]
          inp_img_path = image_paths[idx]
          inp_img_path = ("_").join(
              ("/").join(inp_img_path.split("/")[-3:]).split("_")[:-1]
          )
          filtered_cc_map[inp_img_path] = cc_map[inp_img_path]
          filtered_cc_map[inp_img_path].update(
              {
                  "prediction": [
                      id_to_label[item] for item in predictions[item]
                  ],
                  "orig_path": image_paths[idx],
              }
          )
          if has_confidence_scores:
              filtered_cc_map[inp_img_path].update(
                  {
                      "confidence_scores": filtered_confidence_scores[
                          item
                      ]
                  }
              )
      print(f"Output data entries: {len(list(filtered_cc_map.keys()))}")
      return filtered_cc_map, label_to_id
  
file_path: vissl/projects/fairness_indicators/harmful_label_associations/inference_label_assoc_casual_conversations.py
imports: import numpy
  import pandas
  from fvcore.common.file_io import PathManager
  from PIL import Image
  from vissl.utils.io import load_file
label_desc: Use image node_id 5 for calling a global function with example usage: load_cc_face_crops_labels_images_preds_metadata(input_data, confidence_threshold) and returns: filtered_cc_map,  label_to_id