code: def test_dirichlet_multinomial_log_prob(
      total_count, batch_shape, is_sparse
  ):
      event_shape = (3,)
      concentration = torch.rand(batch_shape + event_shape).exp()
      # test on one-hots
      value = total_count * torch.eye(3).reshape(
          event_shape + (1,) * len(batch_shape) + event_shape
      )
  
      num_samples = 100000
      probs = dist.Dirichlet(concentration).sample((num_samples, 1))
      log_probs = dist.Multinomial(total_count, probs).log_prob(value)
      assert (
          log_probs.shape == (num_samples,) + event_shape + batch_shape
      )
      expected = log_probs.logsumexp(0) - math.log(num_samples)
  
      actual = DirichletMultinomial(
          concentration, total_count, is_sparse
      ).log_prob(value)
      assert_close(actual, expected, atol=0.05)
  
file_path: pyro/tests/distributions/test_conjugate.py
imports: import math
  import pytest
  import torch
  import pyro.distributions
  from pyro.distributions import BetaBinomial, DirichletMultinomial, GammaPoisson
  from tests.common import assert_close
label_desc: Use image node_id 5 for calling a global function with example usage: test_dirichlet_multinomial_log_prob(total_count, batch_shape, is_sparse) without return types