class_docstr: Compute F1 scores.
  
  Args:
      num_classes (int): Number of labels.
      key (str): The key name of the predicted and ground truth labels.
          Defaults to 'labels'.
      mode (str or list[str]): Options are:
          - 'micro': Calculate metrics globally by counting the total true
            positives, false negatives and false positives.
          - 'macro': Calculate metrics for each label, and find their
            unweighted mean.
          If mode is a list, then metrics in mode will be calculated
          separately. Defaults to 'micro'.
      cared_classes (list[int]): The indices of the labels particpated in
          the metirc computing. If both ``cared_classes`` and
          ``ignored_classes`` are empty, all classes will be taken into
          account. Defaults to []. Note: ``cared_classes`` and
          ``ignored_classes`` cannot be specified together.
      ignored_classes (list[int]): The index set of labels that are ignored
          when computing metrics. If both ``cared_classes`` and
          ``ignored_classes`` are empty, all classes will be taken into
          account. Defaults to []. Note: ``cared_classes`` and
          ``ignored_classes`` cannot be specified together.
      collect_device (str): Device name used for collecting results from
          different ranks during distributed training. Must be 'cpu' or
          'gpu'. Defaults to 'cpu'.
      prefix (str, optional): The prefix that will be added in the metric
          names to disambiguate homonymous metrics of different evaluators.
          If prefix is not provided in the argument, self.default_prefix
          will be used instead. Defaults to None.
  
  Warning:
      Only non-negative integer labels are involved in computing. All
      negative ground truth labels will be ignored.
docstr: Compute the F1-score based on the true positives, false positives
  and false negatives.
  
  Args:
      tp (Tensor): The true positives.
      fp (Tensor): The false positives.
      fn (Tensor): The false negatives.
  
  Returns:
      float: The F1-score.
docstr_tok: ["Compute","the","F1-score","based","on","the","true","positives",",","false","positives","and","false","negatives",".","Args",":","tp","(","Tensor",")",":","The","true","positives",".","fp","(","Tensor",")",":","The","false","positives",".","fn","(","Tensor",")",":","The","false","negatives",".","Returns",":","float",":","The","F1-score","."]
code: def _compute_f1(
      self, tp: torch.Tensor, fp: torch.Tensor, fn: torch.Tensor
  ) -> float:
      """Compute the F1-score based on the true positives, false positives
      and false negatives.
  
      Args:
          tp (Tensor): The true positives.
          fp (Tensor): The false positives.
          fn (Tensor): The false negatives.
  
      Returns:
          float: The F1-score.
      """
      precision = tp / (tp + fp).clamp(min=1e-8)
      recall = tp / (tp + fn).clamp(min=1e-8)
      f1 = 2 * precision * recall / (precision + recall).clamp(min=1e-8)
      return float(f1.mean())
  
file_path: mmocr/mmocr/evaluation/metrics/f_metric.py
imports: from typing import Dict, Optional, Sequence, Union
  import torch
  from mmengine.evaluator import BaseMetric
  from mmocr.registry import METRICS
label_desc: Use image node_id 4 for calling the F1Metric obj's underlying member method code with example usage: obj._compute_f1(tp, fp, fn) and returns: float