class_docstr: Implements discrete distribution where the underlying random variable
  takes a value from the finite set `values` with the corresponding
  probabilities.
  
  Note: `values` can have duplicates in which case the probability mass
  of duplicates is added up.
  
  A natural loss function, especially given that the new observation does
  not have to be from the finite set `values`, is ranked probability score
  (RPS). For this reason and to be consitent with terminology of other
  models, `log_prob` is implemented as the negative RPS.
class_docstr_tok: ["Implements","discrete","distribution","where","the","underlying","random","variable","takes","a","value","from","the","finite","set","`","values","`","with","the","corresponding","probabilities",".","Note",":","`","values","`","can","have","duplicates","in","which","case","the","probability","mass","of","duplicates","is","added","up",".","A","natural","loss","function",",","especially","given","that","the","new","observation","does","not","have","to","be","from","the","finite","set","`","values","`",",","is","ranked","probability","score","(","RPS",")",".","For","this","reason","and","to","be","consitent","with","terminology","of","other","models",",","`","log_prob","`","is","implemented","as","the","negative","RPS","."]
code: def __init__(
      self,
      values: torch.Tensor,
      probs: torch.Tensor,
      validate_args: Optional[bool] = None,
  ):
      if validate_args:
          total_prob = probs.sum(dim=1)
          assert torch.allclose(total_prob, torch.ones_like(total_prob))
  
      self.values = values
      self.probs = probs
      self.values_sorted, ix_sorted = torch.sort(values, dim=1)
      self.probs_sorted = probs[
          torch.arange(values.shape[0]).unsqueeze(-1), ix_sorted
      ]
      self.CDF = torch.cumsum(self.probs_sorted, dim=1)
  
      if isinstance(values, Number) and isinstance(probs, Number):
          batch_shape = torch.Size()
      else:
          batch_shape = self.values_sorted[:, 0:1].size()
      super().__init__(batch_shape, validate_args=validate_args)
  
file_path: gluonts/src/gluonts/torch/distributions/discrete_distribution.py
imports: from numbers import Number
  from typing import Optional
  import torch
label_desc: Use image node_id 1 to create a new DiscreteDistribution object from inherited base classes: torch.distributions with example: obj = DiscreteDistribution(values, probs, validate_args)