class_docstr: Binary focal loss.
  
  This implements the "star" algorithm from the appendix of the focal loss paper.
  
  Parameters
  ----------
  gamma
  beta
  
  References
  ----------
  1. [Lin, T.Y., Goyal, P., Girshick, R., He, K. and Dollár, P., 2017. Focal loss for dense object detection. In Proceedings of the IEEE international conference on computer vision (pp. 2980-2988)](https://arxiv.org/pdf/1708.02002.pdf)
class_docstr_tok: ["Binary","focal","loss",".","This","implements","the","``","star","''","algorithm","from","the","appendix","of","the","focal","loss","paper",".","Parameters","--","--","--","--","--","gamma","beta","References","--","--","--","--","--","1",".","[","Lin",",","T.Y.",",","Goyal",",","P.",",","Girshick",",","R.",",","He",",","K.","and","Doll\u00e1r",",","P.",",","2017",".","Focal","loss","for","dense","object","detection",".","In","Proceedings","of","the","IEEE","international","conference","on","computer","vision","(","pp",".","2980-2988",")","]","(","https",":","\/\/arxiv.org\/pdf\/1708.02002.pdf",")"]
code: def gradient(self, y_true, y_pred):
      y_true = y_true * 2 - 1  # [0, 1] -> [-1, 1]
  
      xt = y_true * y_pred
  
      if isinstance(y_true, np.ndarray):
          pt = 1.0 / (1 + np.exp(-(self.gamma * xt + self.beta)))
          return y_true * (pt - 1)
  
      pt = utils.math.sigmoid(self.gamma * xt + self.beta)
      return y_true * (pt - 1)
  
imports: from __future__ import annotations
  import math
  import numpy
  from scipy import special
  from river import base, utils
  from river.optim.base import Loss
label_desc: Use image node_id 3 for calling the BinaryFocalLoss obj's underlying member method code with example usage: obj.gradient(y_true, y_pred) and returns: unknown, unknown