class_docstr: Gamma distribution.
  
  Parameters
  ----------
  alpha
      Tensor containing the shape parameters, of shape
      `(*batch_shape, *event_shape)`.
  beta
      Tensor containing the rate parameters, of shape
      `(*batch_shape, *event_shape)`.
  F
class_docstr_tok: ["Gamma","distribution",".","Parameters","--","--","--","--","--","alpha","Tensor","containing","the","shape","parameters",",","of","shape","`","(","*","batch_shape",",","*","event_shape",")","`",".","beta","Tensor","containing","the","rate","parameters",",","of","shape","`","(","*","batch_shape",",","*","event_shape",")","`",".","F"]
code: def log_prob(self, x: Tensor) -> Tensor:
      F = self.F
      alpha, beta = self.alpha, self.beta
  
      def gamma_log_prob(x, alpha, beta):
          return (
              alpha * F.log(beta)
              - F.gammaln(alpha)
              + (alpha - 1) * F.log(x)
              - beta * x
          )
  
      # The gamma_log_prob(x) above returns NaNs for x<=0. Wherever there are
      # NaN in either of the F.where() conditional vectors, then F.where
      # () returns NaN at that entry as well, due to its indicator function
      # multiplication: 1*f(x) + np.nan*0 = nan, since np.nan*0 return
      # nan.
      # Therefore replacing gamma_log_prob(x) with gamma_log_prob(abs
      # (x) mitigates nan returns in cases of x<=0 without altering the
      # value in cases of x>0. This is a known issue in pytorch as well
      # https://github.com/pytorch/pytorch/issues/12986.
  
      # mask zeros to prevent NaN gradients for x==0
      x_masked = F.where(x == 0, x.ones_like() * 0.5, x)
  
      return F.where(
          x > 0,
          gamma_log_prob(F.abs(x_masked), alpha, beta),
          -(10.0**15) * F.ones_like(x),
      )
  
imports: from functools import partial
  from typing import Dict, List, Optional, Tuple
  import numpy
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
  from .distribution import Distribution, _sample_multiple, getF, softplus
  from .distribution_output import DistributionOutput
label_desc: Use image node_id 6 for calling the Gamma obj's underlying member method code with example usage: obj.log_prob(x) and returns: F, unknown