class_docstr: Computes F-1 Score.
  
  It is the harmonic mean of precision and recall.
  Output range is `[0, 1]`. Works for both multi-class
  and multi-label classification.
  
  $$
  F_1 = 2 \cdot \frac{\textrm{precision} \cdot \textrm{recall}}{\textrm{precision}
        + \textrm{recall}}
  $$
  
  Args:
      num_classes: Number of unique classes in the dataset.
      average: Type of averaging to be performed on data.
          Acceptable values are `None`, `micro`, `macro`
          and `weighted`. Default value is None.
      threshold: Elements of `y_pred` above threshold are
          considered to be 1, and the rest 0. If threshold is
          None, the argmax is converted to 1, and the rest 0.
      name: (Optional) String name of the metric instance.
      dtype: (Optional) Data type of the metric result.
  
  Returns:
      F-1 Score: float.
  
  Raises:
      ValueError: If the `average` has values other than
      [None, 'micro', 'macro', 'weighted'].
  
  `average` parameter behavior:
      None: Scores for each class are returned
  
      micro: True positivies, false positives and
          false negatives are computed globally.
  
      macro: True positivies, false positives and
          false negatives are computed for each class
          and their unweighted mean is returned.
  
      weighted: Metrics are computed for each class
          and returns the mean weighted by the
          number of true instances in each class.
  
  Usage:
  
  >>> metric = tfa.metrics.F1Score(num_classes=3, threshold=0.5)
  >>> y_true = np.array([[1, 1, 1],
  ...                    [1, 0, 0],
  ...                    [1, 1, 0]], np.int32)
  >>> y_pred = np.array([[0.2, 0.6, 0.7],
  ...                    [0.2, 0.6, 0.6],
  ...                    [0.6, 0.8, 0.0]], np.float32)
  >>> metric.update_state(y_true, y_pred)
  >>> result = metric.result()
  >>> result.numpy()
  array([0.5      , 0.8      , 0.6666667], dtype=float32)
code: def __init__(
      self,
      num_classes: TensorLike,
      average: Optional[str] = None,
      threshold: Optional[TensorLike] = None,
      name: str = "f1_score",
      dtype: Any = None,
  ):
      super().__init__(
          num_classes, average, 1.0, threshold, name=name, dtype=dtype
      )
  
file_path: rasa/rasa/utils/tensorflow/metrics.py
imports: import tensorflow
  from tensorflow.keras import backend
  from tensorflow.types.experimental import TensorLike
  from typing import Any, Dict, Optional
label_desc: Use image node_id 1 to create a new F1Score object from inherited base classes: FBetaScore with example: obj = F1Score(num_classes, average, threshold, name, dtype)