class_docstr: Meter to calculate mean AP metric for multi-label image classification task.
  
  Args:
      meters_config (AttrDict): config containing the meter settings
  
  meters_config should specify the num_classes
class_docstr_tok: ["Meter","to","calculate","mean","AP","metric","for","multi-label","image","classification","task",".","Args",":","meters_config","(","AttrDict",")",":","config","containing","the","meter","settings","meters_config","should","specify","the","num_classes"]
docstr: Value of the meter globally synced. mean AP and AP for each class is returned
docstr_tok: ["Value","of","the","meter","globally","synced",".","mean","AP","and","AP","for","each","class","is","returned"]
code: def value(self):
      """
      Value of the meter globally synced. mean AP and AP for each class is returned
      """
      _, distributed_rank = get_machine_local_and_dist_rank()
      logging.info(
          f"Rank: {distributed_rank} Mean AP meter: "
          f"scores: {self._scores.shape}, target: {self._targets.shape}"
      )
      ap_matrix = torch.ones(self.num_classes, dtype=torch.float32) * -1
      # targets matrix = 0, 1, -1
      # unknown matrix = 0, 1 where 1 means that it's an unknown
      unknown_matrix = (
          torch.eq(self._targets, -1.0).float().detach().numpy()
      )
      for cls_num in range(self.num_classes):
          # compute AP only for classes that have at least one positive example
          num_pos = len(torch.where(self._targets[:, cls_num] == 1)[0])
          if num_pos == 0:
              continue
          P, R, score, ap = get_precision_recall(
              self._targets[:, cls_num].detach().numpy(),
              self._scores[:, cls_num].detach().numpy(),
              (unknown_matrix[:, cls_num] == 0).astype(float),
          )
          ap_matrix[cls_num] = ap[0]
      nonzero_indices = torch.nonzero(ap_matrix != -1)
      if nonzero_indices.shape[0] < self.num_classes:
          logging.info(
              f"{nonzero_indices.shape[0]} out of {self.num_classes} classes "
              "have meaningful average precision"
          )
      mean_ap = ap_matrix[nonzero_indices].mean().item()
      return {"mAP": mean_ap, "AP": ap_matrix}
  
imports: import logging
  import numpy
  import torch
  from classy_vision.generic.distributed_util import all_reduce_sum, gather_from_all
  from classy_vision.meters import ClassyMeter, register_meter
  from vissl.config import AttrDict
  from vissl.utils.env import get_machine_local_and_dist_rank
  from vissl.utils.svm_utils.evaluate import get_precision_recall
label_desc: Use image node_id 4 for calling the MeanAPMeter obj's underlying member method code with example usage: obj.value() and returns: dict