class_docstr: Creates a Binomial distribution parameterized by :attr:`total_count` and
  either :attr:`probs` or :attr:`logits` (but not both). :attr:`total_count` must be
  broadcastable with :attr:`probs`/:attr:`logits`.
  
  Example::
  
      >>> # xdoctest: +IGNORE_WANT("non-deterministic")
      >>> m = Binomial(100, torch.tensor([0 , .2, .8, 1]))
      >>> x = m.sample()
      tensor([   0.,   22.,   71.,  100.])
  
      >>> m = Binomial(torch.tensor([[5.], [10.]]), torch.tensor([0.5, 0.8]))
      >>> x = m.sample()
      tensor([[ 4.,  5.],
              [ 7.,  6.]])
  
  Args:
      total_count (int or Tensor): number of Bernoulli trials
      probs (Tensor): Event probabilities
      logits (Tensor): Event log-odds
class_docstr_tok: ["Creates","a","Binomial","distribution","parameterized","by",":","attr",":","`","total_count","`","and","either",":","attr",":","`","probs","`","or",":","attr",":","`","logits","`","(","but","not","both",")",".",":","attr",":","`","total_count","`","must","be","broadcastable","with",":","attr",":","`","probs","`","\/",":","attr",":","`","logits","`",".","Example",":",":",">",">",">","#","xdoctest",":","+IGNORE_WANT","(","``","non-deterministic","''",")",">",">",">","m","=","Binomial","(","100",",","torch.tensor","(","[","0",",",".2",",",".8",",","1","]",")",")",">",">",">","x","=","m.sample","(",")","tensor","(","[","0.",",","22.",",","71.",",","100",".","]",")",">",">",">","m","=","Binomial","(","torch.tensor","(","[","[","5",".","]",",","[","10",".","]","]",")",",","torch.tensor","(","[","0.5",",","0.8","]",")",")",">",">",">","x","=","m.sample","(",")","tensor","(","[","[","4.",",","5",".","]",",","[","7.",",","6",".","]","]",")","Args",":","total_count","(","int","or","Tensor",")",":","number","of","Bernoulli","trials","probs","(","Tensor",")",":","Event","probabilities","logits","(","Tensor",")",":","Event","log-odds"]
code: def log_prob(self, value):
      if self._validate_args:
          self._validate_sample(value)
      log_factorial_n = torch.lgamma(self.total_count + 1)
      log_factorial_k = torch.lgamma(value + 1)
      log_factorial_nmk = torch.lgamma(self.total_count - value + 1)
      # k * log(p) + (n - k) * log(1 - p) = k * (log(p) - log(1 - p)) + n * log(1 - p)
      #     (case logit < 0)              = k * logit - n * log1p(e^logit)
      #     (case logit > 0)              = k * logit - n * (log(p) - log(1 - p)) + n * log(p)
      #                                   = k * logit - n * logit - n * log1p(e^-logit)
      #     (merge two cases)             = k * logit - n * max(logit, 0) - n * log1p(e^-|logit|)
      normalize_term = (
          self.total_count * _clamp_by_zero(self.logits)
          + self.total_count
          * torch.log1p(torch.exp(-torch.abs(self.logits)))
          - log_factorial_n
      )
      return (
          value * self.logits
          - log_factorial_k
          - log_factorial_nmk
          - normalize_term
      )
  
imports: import torch
  from torch.distributions import constraints
  from torch.distributions.distribution import Distribution
  from torch.distributions.utils import broadcast_all, lazy_property, logits_to_probs, probs_to_logits
label_desc: Use image node_id 12 for calling the Binomial obj's underlying member method code with example usage: obj.log_prob(value) and returns: unknown