code: def test_sample_phylo(num_leaves, dtype, bp_iters):
      logits, times = random_phylo_logits(num_leaves, dtype)
      num_sources, num_destins = logits.shape
      d = dist.OneTwoMatching(logits, bp_iters=bp_iters)
  
      # Compute an empirical mean.
      num_samples = 1000
      s = torch.arange(num_sources)
      actual = torch.zeros_like(logits)
      with xfail_if_not_implemented():
          for v in d.sample([num_samples]):
              actual[s, v] += 1 / num_samples
  
      # Compute truth via enumeration.
      values = d.enumerate_support()
      probs = d.log_prob(values).exp()
      probs /= probs.sum()
      expected = torch.zeros(num_sources, num_destins)
      for v, p in zip(values, probs):
          expected[s, v] += p
      assert_close(actual, expected, atol=0.1)
  
imports: import logging
  import math
  import pytest
  import torch
  import pyro.distributions
  from tests.common import assert_close, assert_equal, xfail_if_not_implemented
label_desc: Use image node_id 19 for calling a global function with example usage: test_sample_phylo(num_leaves, dtype, bp_iters) without return types