class_docstr: Abstract class to calculate the TP, FP, FN and runs an evaluating function on the result.
  
  Parameters
  ----------
  iou_thres: float, default: 0.5
      IoU below this threshold will be ignored.
  confidence_thres: float, default: 0.5
      Confidence below this threshold will be ignored.
  evaluating_function: Union[Callable, str], default: "recall"
      will run on each class result i.e `func(tp, fp, fn)`
  averaging_method : str, default: 'per_class'
      Determines which averaging method to apply, possible values are:
      'per_class': Return a np array with the scores for each class (sorted by class name).
      'binary': Returns the score for the positive class. Should be used only in binary classification cases.
      'micro': Returns the micro-averaged score.
      'macro': Returns the mean of scores per class.
      'weighted': Returns a weighted mean of scores based of the class size in y_true.
class_docstr_tok: ["Abstract","class","to","calculate","the","TP",",","FP",",","FN","and","runs","an","evaluating","function","on","the","result",".","Parameters","--","--","--","--","--","iou_thres",":","float",",","default",":","0.5","IoU","below","this","threshold","will","be","ignored",".","confidence_thres",":","float",",","default",":","0.5","Confidence","below","this","threshold","will","be","ignored",".","evaluating_function",":","Union","[","Callable",",","str","]",",","default",":","``","recall","''","will","run","on","each","class","result","i.e","`","func","(","tp",",","fp",",","fn",")","`","averaging_method",":","str",",","default",":","'per_class'","Determines","which","averaging","method","to","apply",",","possible","values","are",":","'per_class","'",":","Return","a","np","array","with","the","scores","for","each","class","(","sorted","by","class","name",")",".","'binary","'",":","Returns","the","score","for","the","positive","class",".","Should","be","used","only","in","binary","classification","cases",".","'micro","'",":","Returns","the","micro-averaged","score",".","'macro","'",":","Returns","the","mean","of","scores","per","class",".","'weighted","'",":","Returns","a","weighted","mean","of","scores","based","of","the","class","size","in","y_true","."]
docstr: Compute metric value.
docstr_tok: ["Compute","metric","value","."]
code: def compute(self):
      """Compute metric value."""
      # now reduce accumulations
      sorted_classes = [
          int(class_id) for class_id in sorted(self._evals.keys())
      ]
      max_class = max(sorted_classes)
  
      if self.averaging_method == "micro":
          tp, fp, fn = 0, 0, 0
          # Classes that did not appear in the data are not considered as part of micro averaging.
          for class_id in sorted_classes:
              ev = self._evals[class_id]
              tp, fp, fn = tp + ev["tp"], fp + ev["fp"], fn + ev["fn"]
          return self.evaluating_function(tp, fp, fn)
  
      scores_per_class, weights = -np.ones(max_class + 1), np.zeros(
          max_class + 1
      )
      for class_id in sorted_classes:
          ev = self._evals[class_id]
          scores_per_class[class_id] = self.evaluating_function(
              ev["tp"], ev["fp"], ev["fn"]
          )
          weights[class_id] = ev["tp"] + ev["fn"]
  
      return averaging_mechanism(
          self.averaging_method, scores_per_class, weights
      )
  
imports: import typing
  from collections import defaultdict
  import numpy
  from ignite.metrics import Metric
  from ignite.metrics.metric import reinit__is_reduced, sync_all_reduce
  from deepchecks.utils.metrics import averaging_mechanism
  from deepchecks.vision.metrics_utils.confusion_matrix_counts_metrics import AVAILABLE_EVALUATING_FUNCTIONS
  from deepchecks.vision.metrics_utils.metric_mixin import MetricMixin, ObjectDetectionMetricMixin
  from deepchecks.vision.vision_data.utils import is_torch_object
label_desc: Use image node_id 4 for calling the TpFpFn obj's underlying member method code with example usage: obj.compute() and returns: averaging_mechanism, self