class_docstr: Half Gamma deviance loss with log-link, for regression.
  
  Domain:
  y_true and y_pred in positive real numbers
  
  Link:
  y_pred = exp(raw_prediction)
  
  For a given sample x_i, half Gamma deviance loss is defined as::
  
      loss(x_i) = log(exp(raw_prediction_i)/y_true_i)
                  + y_true/exp(raw_prediction_i) - 1
  
  Half the Gamma deviance is actually proportional to the negative log-
  likelihood up to constant terms (not involving raw_prediction) and
  simplifies the computation of the gradients.
  We also skip the constant term `-log(y_true_i) - 1`.
class_docstr_tok: ["Half","Gamma","deviance","loss","with","log-link",",","for","regression",".","Domain",":","y_true","and","y_pred","in","positive","real","numbers","Link",":","y_pred","=","exp","(","raw_prediction",")","For","a","given","sample","x_i",",","half","Gamma","deviance","loss","is","defined","as",":",":","loss","(","x_i",")","=","log","(","exp","(","raw_prediction_i",")","\/y_true_i",")","+","y_true\/exp","(","raw_prediction_i",")","-","1","Half","the","Gamma","deviance","is","actually","proportional","to","the","negative","log-","likelihood","up","to","constant","terms","(","not","involving","raw_prediction",")","and","simplifies","the","computation","of","the","gradients",".","We","also","skip","the","constant","term","`","-log","(","y_true_i",")","-","1","`","."]
code: def constant_to_optimal_zero(self, y_true, sample_weight=None):
      term = -np.log(y_true) - 1
      if sample_weight is not None:
          term *= sample_weight
      return term
  
imports: import numbers
  import numpy
  from scipy.special import xlogy
  from ..utils import check_scalar
  from ..utils.stats import _weighted_percentile
  from ._loss import CyAbsoluteError, CyExponentialLoss, CyHalfBinomialLoss, CyHalfGammaLoss, CyHalfMultinomialLoss, CyHalfPoissonLoss, CyHalfSquaredError, CyHalfTweedieLoss, CyHalfTweedieLossIdentity, CyHuberLoss, CyPinballLoss
  from .link import HalfLogitLink, IdentityLink, Interval, LogitLink, LogLink, MultinomialLogit
label_desc: Use image node_id 2 for calling the HalfGammaLoss obj's underlying member method code with example usage: obj.constant_to_optimal_zero(y_true, sample_weight) and returns: term