code: def test_likelihood_sequential(
      num_leaves, num_steps, batch_shape, clamped
  ):
      if clamped:
          leaf_times = (
              torch.rand(batch_shape + (num_leaves,)).pow(0.5)
              * num_steps
          )
          coal_times = CoalescentTimes(leaf_times).sample().clamp(min=0)
      else:
          leaf_times = torch.randn(batch_shape + (num_leaves,))
          leaf_times.mul_(0.25).add_(0.75).mul_(num_steps)
          coal_times = CoalescentTimes(leaf_times).sample()
  
      rate_grid = torch.rand(batch_shape + (num_steps,)) + 0.5
  
      d = CoalescentTimesWithRate(leaf_times, rate_grid)
      expected = d.log_prob(coal_times)
  
      likelihood = CoalescentRateLikelihood(
          leaf_times, coal_times, num_steps
      )
      actual = sum(
          likelihood(rate_grid[..., t], t) for t in range(num_steps)
      )
  
      assert_close(actual, expected)
  
imports: import io
  import re
  import pytest
  import torch
  import pyro
  from pyro.distributions import CoalescentTimes, CoalescentTimesWithRate
  from pyro.distributions.coalescent import CoalescentRateLikelihood, CoalescentTimesConstraint, _sample_coalescent_times, bio_phylo_to_times
  from pyro.distributions.util import broadcast_shape
  from tests.common import assert_close
label_desc: Use image node_id 9 for calling a global function with example usage: test_likelihood_sequential(num_leaves, num_steps, batch_shape, clamped) without return types