keras/src/metrics/f_score_metrics.py/FBetaScore/result
class FBetaScore:    def result(self):
        precision = ops.divide(
            self.true_positives,
            self.true_positives + self.false_positives + backend.epsilon(),
        )
        recall = ops.divide(
            self.true_positives,
            self.true_positives + self.false_negatives + backend.epsilon(),
        )

        precision = ops.convert_to_tensor(precision, dtype=self.dtype)
        recall = ops.convert_to_tensor(recall, dtype=self.dtype)

        mul_value = precision * recall
        add_value = ((self.beta**2) * precision) + recall
        mean = ops.divide(mul_value, add_value + backend.epsilon())
        f1_score = mean * (1 + (self.beta**2))

        if self.average == "weighted":
            weights = ops.divide(
                self.intermediate_weights,
                ops.sum(self.intermediate_weights) + backend.epsilon(),
            )
            f1_score = ops.sum(f1_score * weights)

        elif self.average is not None:  # [micro, macro]
            f1_score = ops.mean(f1_score)

        return f1_score