class_docstr: Association without ground truth, from: Aka, O.; Burke, K.; Bäuerle, A.;
  Greer, C.; and Mitchell, M. 2021. Measuring model biases in the absence of ground
  truth. arXiv preprint arXiv:2103.03417.
  
  # Parameters
  
  num_classes : `int`
      Number of classes.
  num_protected_variable_labels : `int`
      Number of protected variable labels.
  association_metric : `str`, optional (default = `"npmixy"`).
      A generic association metric A(x, y), where x is an identity label and y is any other label.
      Examples include: nPMIxy (`"npmixy"`), nPMIy (`"npmiy"`), PMI^2 (`"pmisq"`), PMI (`"pmi"`)
      Empirically, nPMIxy and nPMIy are more capable of capturing labels across a range of
      marginal frequencies.
  gap_type : `str`, optional (default = `"ova"`).
      Either one-vs-all (`"ova"`) or pairwise (`"pairwise"`). One-vs-all gap is equivalent to
      A(x, y) - E[A(x', y)], where x' is in the set of all protected variable labels setminus {x}.
      Pairwise gaps are A(x, y) - A(x', y), for all x' in the set of all protected variable labels
      setminus {x}.
  
  !!! Note
      Assumes integer predictions, with each item to be classified
      having a single correct class.
class_docstr_tok: ["Association","without","ground","truth",",","from",":","Aka",",","O.",";","Burke",",","K.",";","B\u00e4uerle",",","A.",";","Greer",",","C.",";","and","Mitchell",",","M.","2021",".","Measuring","model","biases","in","the","absence","of","ground","truth",".","arXiv","preprint","arXiv:2103.03417",".","#","Parameters","num_classes",":","`","int","`","Number","of","classes",".","num_protected_variable_labels",":","`","int","`","Number","of","protected","variable","labels",".","association_metric",":","`","str","`",",","optional","(","default","=","`","``","npmixy","''","`",")",".","A","generic","association","metric","A","(","x",",","y",")",",","where","x","is","an","identity","label","and","y","is","any","other","label",".","Examples","include",":","nPMIxy","(","`","``","npmixy","''","`",")",",","nPMIy","(","`","``","npmiy","''","`",")",",","PMI^2","(","`","``","pmisq","''","`",")",",","PMI","(","`","``","pmi","''","`",")","Empirically",",","nPMIxy","and","nPMIy","are","more","capable","of","capturing","labels","across","a","range","of","marginal","frequencies",".","gap_type",":","`","str","`",",","optional","(","default","=","`","``","ova","''","`",")",".","Either","one-vs-all","(","`","``","ova","''","`",")","or","pairwise","(","`","``","pairwise","''","`",")",".","One-vs-all","gap","is","equivalent","to","A","(","x",",","y",")","-","E","[","A","(","x","'",",","y",")","]",",","where","x","'","is","in","the","set","of","all","protected","variable","labels","setminus","{","x","}",".","Pairwise","gaps","are","A","(","x",",","y",")","-","A","(","x","'",",","y",")",",","for","all","x","'","in","the","set","of","all","protected","variable","labels","setminus","{","x","}",".","!","!","!","Note","Assumes","integer","predictions",",","with","each","item","to","be","classified","having","a","single","correct","class","."]
docstr: # Returns
  
  gaps : `Dict[int, Union[torch.FloatTensor, Dict[int, torch.FloatTensor]]]`
      A dictionary mapping each protected variable label x to either:
  
      1. a tensor of the one-vs-all gaps (where the gap corresponding to prediction
      label i is at index i),
  
      2. another dictionary mapping protected variable labels x' to a tensor
      of the pairwise gaps (where the gap corresponding to prediction label i is at index i).
      A gap of nearly 0 implies fairness on the basis of Association in the Absence of Ground Truth.
  
  !!! Note
      If a possible class label is not present in Y, the expected behavior is that
      the gaps corresponding to this class label are NaN. If a possible (class label,
      protected variable label) pair is not present in the joint of Y and X, the expected
      behavior is that the gap corresponding to this (class label, protected variable label)
      pair is NaN.
docstr_tok: ["#","Returns","gaps",":","`","Dict","[","int",",","Union","[","torch.FloatTensor",",","Dict","[","int",",","torch.FloatTensor","]","]","]","`","A","dictionary","mapping","each","protected","variable","label","x","to","either",":","1.","a","tensor","of","the","one-vs-all","gaps","(","where","the","gap","corresponding","to","prediction","label","i","is","at","index","i",")",",","2.","another","dictionary","mapping","protected","variable","labels","x","'","to","a","tensor","of","the","pairwise","gaps","(","where","the","gap","corresponding","to","prediction","label","i","is","at","index","i",")",".","A","gap","of","nearly","0","implies","fairness","on","the","basis","of","Association","in","the","Absence","of","Ground","Truth",".","!","!","!","Note","If","a","possible","class","label","is","not","present","in","Y",",","the","expected","behavior","is","that","the","gaps","corresponding","to","this","class","label","are","NaN",".","If","a","possible","(","class","label",",","protected","variable","label",")","pair","is","not","present","in","the","joint","of","Y","and","X",",","the","expected","behavior","is","that","the","gap","corresponding","to","this","(","class","label",",","protected","variable","label",")","pair","is","NaN","."]
code: def get_metric(
      self, reset: bool = False
  ) -> Dict[int, Union[torch.Tensor, Dict[int, torch.Tensor]]]:
      """
      # Returns
  
      gaps : `Dict[int, Union[torch.FloatTensor, Dict[int, torch.FloatTensor]]]`
          A dictionary mapping each protected variable label x to either:
  
          1. a tensor of the one-vs-all gaps (where the gap corresponding to prediction
          label i is at index i),
  
          2. another dictionary mapping protected variable labels x' to a tensor
          of the pairwise gaps (where the gap corresponding to prediction label i is at index i).
          A gap of nearly 0 implies fairness on the basis of Association in the Absence of Ground Truth.
  
      !!! Note
          If a possible class label is not present in Y, the expected behavior is that
          the gaps corresponding to this class label are NaN. If a possible (class label,
          protected variable label) pair is not present in the joint of Y and X, the expected
          behavior is that the gap corresponding to this (class label, protected variable label)
          pair is NaN.
      """
      gaps = {}
      for x in range(self._num_protected_variable_labels):
          gaps[x] = self.gap_func(x)
      if reset:
          self.reset()
      return gaps
  
imports: from typing import Optional, Dict, Union, List
  import torch
  import torch.distributed
  from allennlp.common.util import is_distributed
  from allennlp.common.checks import ConfigurationError
  from allennlp.nn.util import dist_reduce_sum
  from allennlp.training.metrics.metric import Metric
label_desc: Use image node_id 3 for calling the AssociationWithoutGroundTruth obj's underlying member method code with example usage: obj.get_metric(reset) and returns: gaps