class_docstr: EXPERIMENTAL This is not a :class:`~pyro.distributions.Distribution`, but
  acts as a transposed version of :class:`CoalescentTimesWithRate` making the
  elements of ``rate_grid`` independent and thus compatible with ``plate``
  and ``poutine.markov``. For non-batched inputs the following are all
  equivalent likelihoods::
  
      # Version 1.
      pyro.sample("coalescent",
                  CoalescentTimesWithRate(leaf_times, rate_grid),
                  obs=coal_times)
  
      # Version 2. using pyro.plate
      likelihood = CoalescentRateLikelihood(leaf_times, coal_times, len(rate_grid))
      with pyro.plate("time", len(rate_grid)):
          pyro.factor("coalescent", likelihood(rate_grid))
  
      # Version 3. using pyro.markov
      likelihood = CoalescentRateLikelihood(leaf_times, coal_times, len(rate_grid))
      for t in pyro.markov(range(len(rate_grid))):
          pyro.factor("coalescent_{}".format(t), likelihood(rate_grid[t], t))
  
  The third version is useful for e.g.
  :class:`~pyro.infer.smcfilter.SMCFilter` where ``rate_grid`` might be
  computed sequentially.
  
  :param torch.Tensor leaf_times: Tensor of times of sampling events, i.e.
      leaf nodes in the phylogeny. These can be arbitrary real numbers with
      arbitrary order and duplicates.
  :param torch.Tensor coal_times: A tensor of coalescent times. These denote
      sets of size ``leaf_times.size(-1) - 1`` along the trailing dimension
      and should be sorted along that dimension.
  :param int duration: Size of the rate grid, ``rate_grid.size(-1)``.
class_docstr_tok: ["EXPERIMENTAL","This","is","not","a",":","class",":","`","~pyro.distributions.Distribution","`",",","but","acts","as","a","transposed","version","of",":","class",":","`","CoalescentTimesWithRate","`","making","the","elements","of","``","rate_grid","``","independent","and","thus","compatible","with","``","plate","``","and","``","poutine.markov","``",".","For","non-batched","inputs","the","following","are","all","equivalent","likelihoods",":",":","#","Version","1.","pyro.sample","(","``","coalescent","''",",","CoalescentTimesWithRate","(","leaf_times",",","rate_grid",")",",","obs=coal_times",")","#","Version","2.","using","pyro.plate","likelihood","=","CoalescentRateLikelihood","(","leaf_times",",","coal_times",",","len","(","rate_grid",")",")","with","pyro.plate","(","``","time","''",",","len","(","rate_grid",")",")",":","pyro.factor","(","``","coalescent","''",",","likelihood","(","rate_grid",")",")","#","Version","3.","using","pyro.markov","likelihood","=","CoalescentRateLikelihood","(","leaf_times",",","coal_times",",","len","(","rate_grid",")",")","for","t","in","pyro.markov","(","range","(","len","(","rate_grid",")",")",")",":","pyro.factor","(","``","coalescent_","{","}","''",".format","(","t",")",",","likelihood","(","rate_grid","[","t","]",",","t",")",")","The","third","version","is","useful","for","e.g",".",":","class",":","`","~pyro.infer.smcfilter.SMCFilter","`","where","``","rate_grid","``","might","be","computed","sequentially",".",":","param","torch.Tensor","leaf_times",":","Tensor","of","times","of","sampling","events",",","i.e",".","leaf","nodes","in","the","phylogeny",".","These","can","be","arbitrary","real","numbers","with","arbitrary","order","and","duplicates",".",":","param","torch.Tensor","coal_times",":","A","tensor","of","coalescent","times",".","These","denote","sets","of","size","``","leaf_times.size","(","-1",")","-","1","``","along","the","trailing","dimension","and","should","be","sorted","along","that","dimension",".",":","param","int","duration",":","Size","of","the","rate","grid",",","``","rate_grid.size","(","-1",")","``","."]
docstr: Computes the likelihood of [1] equations 7-9 for one or all time
  points.
  
  **References**
  
  [1] A. Popinga, T. Vaughan, T. Statler, A.J. Drummond (2014)
      "Inferring epidemiological dynamics with Bayesian coalescent
      inference: The merits of deterministic and stochastic models"
      https://arxiv.org/pdf/1407.1792.pdf
  
  :param torch.Tensor rate_grid: Tensor of base coalescent rates
      (pairwise rate of coalescence). For example in a simple SIR model
      this might be ``beta S / I``. The rightmost dimension is time, and
      this tensor represents a (batch of) rates that are piecwise
      constant in time.
  :param time: Optional time index by which the input was sliced, as in
      ``rate_grid[..., t]`` This can be an integer for sequential models
      or ``slice(None)`` for vectorized models.
  :type time: int or slice
  :returns: Likelihood ``p(coal_times | leaf_times, rate_grid)``,
      or a part of that likelihood corresponding to a single time step.
  :rtype: torch.Tensor
docstr_tok: ["Computes","the","likelihood","of","[","1","]","equations","7-9","for","one","or","all","time","points",".","*","*","References","*","*","[","1","]","A.","Popinga",",","T.","Vaughan",",","T.","Statler",",","A.J",".","Drummond","(","2014",")","``","Inferring","epidemiological","dynamics","with","Bayesian","coalescent","inference",":","The","merits","of","deterministic","and","stochastic","models","''","https",":","\/\/arxiv.org\/pdf\/1407.1792.pdf",":","param","torch.Tensor","rate_grid",":","Tensor","of","base","coalescent","rates","(","pairwise","rate","of","coalescence",")",".","For","example","in","a","simple","SIR","model","this","might","be","``","beta","S","\/","I","``",".","The","rightmost","dimension","is","time",",","and","this","tensor","represents","a","(","batch","of",")","rates","that","are","piecwise","constant","in","time",".",":","param","time",":","Optional","time","index","by","which","the","input","was","sliced",",","as","in","``","rate_grid","[","...",",","t","]","``","This","can","be","an","integer","for","sequential","models","or","``","slice","(","None",")","``","for","vectorized","models",".",":","type","time",":","int","or","slice",":","returns",":","Likelihood","``","p","(","coal_times","|","leaf_times",",","rate_grid",")","``",",","or","a","part","of","that","likelihood","corresponding","to","a","single","time","step",".",":","rtype",":","torch.Tensor"]
code: def __call__(self, rate_grid, t=slice(None)):
      """
      Computes the likelihood of [1] equations 7-9 for one or all time
      points.
  
      **References**
  
      [1] A. Popinga, T. Vaughan, T. Statler, A.J. Drummond (2014)
          "Inferring epidemiological dynamics with Bayesian coalescent
          inference: The merits of deterministic and stochastic models"
          https://arxiv.org/pdf/1407.1792.pdf
  
      :param torch.Tensor rate_grid: Tensor of base coalescent rates
          (pairwise rate of coalescence). For example in a simple SIR model
          this might be ``beta S / I``. The rightmost dimension is time, and
          this tensor represents a (batch of) rates that are piecwise
          constant in time.
      :param time: Optional time index by which the input was sliced, as in
          ``rate_grid[..., t]`` This can be an integer for sequential models
          or ``slice(None)`` for vectorized models.
      :type time: int or slice
      :returns: Likelihood ``p(coal_times | leaf_times, rate_grid)``,
          or a part of that likelihood corresponding to a single time step.
      :rtype: torch.Tensor
      """
      const = self._const[..., t]
      linear = self._linear[..., t] * rate_grid
      log = (
          self._log[..., t]
          * rate_grid.clamp(min=torch.finfo(rate_grid.dtype).tiny).log()
      )
      return const + linear + log
  
imports: import functools
  import weakref
  from collections import namedtuple
  import torch
  from torch.distributions import constraints
  from pyro.distributions.util import broadcast_shape, is_validation_enabled
  from pyro.ops.special import safe_log
  from .torch_distribution import TorchDistribution
label_desc: Use image node_id 2 for calling the CoalescentRateLikelihood obj's underlying member method code with example usage: obj.__call__(rate_grid, t) and returns: unknown