    def get_metric(self, reset: bool = False):
        """
        # Returns

        <class>-precision : `float`
        <class>-recall : `float`
        <class>-fscore : `float`
        <avg>-precision : `float`
        <avg>-recall : `float`
        <avg>-fscore : `float`

        where <class> is the index (or the label if `index_to_label` is given)
        of each class; and <avg> is `micro`, `macro` and `weighted`, one for
        each kind of average.
        """
        if self._true_positive_sum is None or self._pred_sum is None or self._true_sum is None:
            raise RuntimeError("You have never called this metric before.")

        tp_sum = self._true_positive_sum
        pred_sum = self._pred_sum
        true_sum = self._true_sum

        if self._labels is not None:
            # Retain only selected labels and order them
            tp_sum = tp_sum[self._labels]
            pred_sum = pred_sum[self._labels]  # type: ignore
            true_sum = true_sum[self._labels]  # type: ignore

        beta2 = self._beta**2

        # Finally, we have all our sufficient statistics.
        precision = nan_safe_tensor_divide(tp_sum, pred_sum)
        recall = nan_safe_tensor_divide(tp_sum, true_sum)
        fscore = nan_safe_tensor_divide(
            (1 + beta2) * precision * recall, beta2 * precision + recall
        )

        all_metrics = {}
        for c, (p, r, f) in enumerate(zip(precision.tolist(), recall.tolist(), fscore.tolist())):
            label = str(c)
            if self._index_to_label:
                label = self._index_to_label[c]
            all_metrics[f"{label}-precision"] = p
            all_metrics[f"{label}-recall"] = r
            all_metrics[f"{label}-fscore"] = f

        # macro average
        all_metrics["macro-precision"] = precision.mean().item()
        all_metrics["macro-recall"] = recall.mean().item()
        all_metrics["macro-fscore"] = fscore.mean().item()

        # weighted average
        weights = true_sum
        weights_sum = true_sum.sum()  # type: ignore
        all_metrics["weighted-precision"] = nan_safe_tensor_divide(
            (weights * precision).sum(), weights_sum
        ).item()
        all_metrics["weighted-recall"] = nan_safe_tensor_divide(
            (weights * recall).sum(), weights_sum
        ).item()
        all_metrics["weighted-fscore"] = nan_safe_tensor_divide(
            (weights * fscore).sum(), weights_sum
        ).item()

        # micro average
        micro_precision = nan_safe_tensor_divide(tp_sum.sum(), pred_sum.sum())
        micro_recall = nan_safe_tensor_divide(tp_sum.sum(), true_sum.sum())
        all_metrics["micro-precision"] = micro_precision.item()
        all_metrics["micro-recall"] = micro_recall.item()
        all_metrics["micro-fscore"] = nan_safe_tensor_divide(
            (1 + beta2) * micro_precision * micro_recall, beta2 * micro_precision + micro_recall
        ).item()

        if reset:
            self.reset()

        return all_metrics
# Returns

<class>-precision : `float`
<class>-recall : `float`
<class>-fscore : `float`
<avg>-precision : `float`
<avg>-recall : `float`
<avg>-fscore : `float`

where <class> is the index (or the label if `index_to_label` is given)
of each class; and <avg> is `micro`, `macro` and `weighted`, one for
each kind of average.
allennlp/training/metrics/fbeta_verbose_measure.py