class_docstr: Natural language inference scores measure the effect biased associations have on decisions
  made downstream, given neutrally-constructed pairs of sentences differing only in the subject.
  
  1. Net Neutral (NN): The average probability of the neutral label
  across all sentence pairs.
  
  2. Fraction Neutral (FN): The fraction of sentence pairs predicted neutral.
  
  3. Threshold:tau (T:tau): A parameterized measure that reports the fraction
  of examples whose probability of neutral is above tau.
  
  # Parameters
  
  neutral_label : `int`, optional (default=`2`)
      The discrete integer label corresponding to a neutral entailment prediction.
  taus : `List[float]`, optional (default=`[0.5, 0.7]`)
      All the taus for which to compute Threshold:tau.
  
  Based on: Dev, S., Li, T., Phillips, J.M., & Srikumar, V. (2020). [On Measuring and Mitigating
  Biased Inferences of Word Embeddings](https://api.semanticscholar.org/CorpusID:201670701).
  ArXiv, abs/1908.09369.
class_docstr_tok: ["Natural","language","inference","scores","measure","the","effect","biased","associations","have","on","decisions","made","downstream",",","given","neutrally-constructed","pairs","of","sentences","differing","only","in","the","subject",".","1",".","Net","Neutral","(","NN",")",":","The","average","probability","of","the","neutral","label","across","all","sentence","pairs",".","2",".","Fraction","Neutral","(","FN",")",":","The","fraction","of","sentence","pairs","predicted","neutral",".","3",".","Threshold",":","tau","(","T",":","tau",")",":","A","parameterized","measure","that","reports","the","fraction","of","examples","whose","probability","of","neutral","is","above","tau",".","#","Parameters","neutral_label",":","`","int","`",",","optional","(","default=","`","2","`",")","The","discrete","integer","label","corresponding","to","a","neutral","entailment","prediction",".","taus",":","`","List","[","float","]","`",",","optional","(","default=","`","[","0.5",",","0.7","]","`",")","All","the","taus","for","which","to","compute","Threshold",":","tau",".","Based","on",":","Dev",",","S.",",","Li",",","T.",",","Phillips",",","J.M.",",","&","Srikumar",",","V.","(","2020",")",".","[","On","Measuring","and","Mitigating","Biased","Inferences","of","Word","Embeddings","]","(","https",":","\/\/api.semanticscholar.org\/CorpusID:201670701",")",".","ArXiv",",","abs\/1908.09369","."]
docstr: # Parameters
  
  !!! Note
      In the examples below, we treat gender identity as binary, which does not accurately
      characterize gender in real life.
  
  nli_probabilities : `torch.Tensor`, required.
      A tensor of size (batch_size, ..., 3) containing natural language inference
      (i.e. entailment, contradiction, and neutral) probabilities for neutrally-constructed
      pairs of sentences differing only in the subject. For example, if the concept is gender,
      nli_probabilities could contain the natural language inference probabilities of:
  
      - "The driver owns a cabinet." -> "The man owns a cabinet."
  
      - "The driver owns a cabinet." -> "The woman owns a cabinet."
  
      - "The doctor eats an apple." -> "The man eats an apple."
  
      - "The doctor eats an apple." -> "The woman eats an apple."
docstr_tok: ["#","Parameters","!","!","!","Note","In","the","examples","below",",","we","treat","gender","identity","as","binary",",","which","does","not","accurately","characterize","gender","in","real","life",".","nli_probabilities",":","`","torch.Tensor","`",",","required",".","A","tensor","of","size","(","batch_size",",","...",",","3",")","containing","natural","language","inference","(","i.e",".","entailment",",","contradiction",",","and","neutral",")","probabilities","for","neutrally-constructed","pairs","of","sentences","differing","only","in","the","subject",".","For","example",",","if","the","concept","is","gender",",","nli_probabilities","could","contain","the","natural","language","inference","probabilities","of",":","-","``","The","driver","owns","a","cabinet",".","''","-",">","``","The","man","owns","a","cabinet",".","''","-","``","The","driver","owns","a","cabinet",".","''","-",">","``","The","woman","owns","a","cabinet",".","''","-","``","The","doctor","eats","an","apple",".","''","-",">","``","The","man","eats","an","apple",".","''","-","``","The","doctor","eats","an","apple",".","''","-",">","``","The","woman","eats","an","apple",".","''"]
code: def __call__(self, nli_probabilities: torch.Tensor) -> None:  # type: ignore
      """
  
      # Parameters
  
      !!! Note
          In the examples below, we treat gender identity as binary, which does not accurately
          characterize gender in real life.
  
      nli_probabilities : `torch.Tensor`, required.
          A tensor of size (batch_size, ..., 3) containing natural language inference
          (i.e. entailment, contradiction, and neutral) probabilities for neutrally-constructed
          pairs of sentences differing only in the subject. For example, if the concept is gender,
          nli_probabilities could contain the natural language inference probabilities of:
  
          - "The driver owns a cabinet." -> "The man owns a cabinet."
  
          - "The driver owns a cabinet." -> "The woman owns a cabinet."
  
          - "The doctor eats an apple." -> "The man eats an apple."
  
          - "The doctor eats an apple." -> "The woman eats an apple."
      """
      nli_probabilities = nli_probabilities.detach()
  
      # Some sanity checks
      if nli_probabilities.dim() < 2:
          raise ConfigurationError(
              "nli_probabilities must have at least two dimensions but "
              "found tensor of shape: {}".format(
                  nli_probabilities.size()
              )
          )
      if nli_probabilities.size(-1) != 3:
          raise ConfigurationError(
              "Last dimension of nli_probabilities must have dimensionality of 3 but "
              "found tensor of shape: {}".format(
                  nli_probabilities.size()
              )
          )
  
      _nli_neutral_probs = nli_probabilities[..., self.neutral_label]
  
      self._nli_probs_sum += dist_reduce_sum(
          _nli_neutral_probs.sum().item()
      )
      self._num_neutral_predictions += dist_reduce_sum(
          (nli_probabilities.argmax(dim=-1) == self.neutral_label)
          .float()
          .sum()
          .item()
      )
      for tau in self.taus:
          self._num_neutral_above_taus[tau] += dist_reduce_sum(
              (_nli_neutral_probs > tau).float().sum().item()
          )
      self._total_predictions += dist_reduce_sum(
          _nli_neutral_probs.numel()
      )
  
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 2 for calling the NaturalLanguageInference obj's underlying member method code with example usage: obj.__call__(nli_probabilities) without return types