code: def test_lnnb_mean_variance(
      total_count,
      multiplicative_noise_scale,
      num_quad_points=128,
      N=512,
  ):
      logits = torch.tensor(2.0)
      d = LogNormalNegativeBinomial(
          total_count,
          logits,
          multiplicative_noise_scale,
          num_quad_points=num_quad_points,
      )
  
      values = torch.arange(N)
      probs = d.log_prob(values).exp()
      assert_close(1.0, probs.sum().item(), atol=1.0e-6)
  
      expected_mean = (probs * values).sum()
      assert_close(expected_mean, d.mean, atol=1.0e-6, rtol=1.0e-5)
  
      expected_var = (probs * (values - d.mean).pow(2.0)).sum()
      assert_close(expected_var, d.variance, atol=1.0e-6, rtol=1.0e-5)
  
imports: import pytest
  import torch
  from pyro.distributions import LogNormalNegativeBinomial
  from tests.common import assert_close
label_desc: Use image node_id 2 for calling a global function with example usage: test_lnnb_mean_variance(total_count, multiplicative_noise_scale, num_quad_points, N) without return types