code: def test_log_normal(batch_shape, event_shape):
      shape = batch_shape + event_shape
      loc = torch.empty(shape).uniform_(-1, 1)
      scale = torch.empty(shape).uniform_(0.5, 1.5)
  
      def model():
          fn = dist.TransformedDistribution(
              dist.Normal(
                  torch.zeros_like(loc), torch.ones_like(scale)
              ),
              [AffineTransform(loc, scale), ExpTransform()],
          )
          if event_shape:
              fn = fn.to_event(len(event_shape))
          with pyro.plate_stack("plates", batch_shape):
              with pyro.plate("particles", 200000):
                  return pyro.sample("x", fn)
  
      with poutine.trace() as tr:
          value = model()
      assert isinstance(
          tr.trace.nodes["x"]["fn"],
          (dist.TransformedDistribution, dist.Independent),
      )
      expected_moments = get_moments(value)
  
      with poutine.reparam(config={"x": TransformReparam()}):
          with poutine.trace() as tr:
              value = model()
      assert isinstance(
          tr.trace.nodes["x"]["fn"],
          (dist.Delta, dist.MaskedDistribution),
      )
      actual_moments = get_moments(value)
      assert_close(actual_moments, expected_moments, atol=0.05)
  
file_path: pyro/tests/infer/reparam/test_transform.py
imports: import pytest
  import torch
  import pyro
  import pyro.distributions
  import pyro.poutine
  from pyro.distributions.transforms import AffineTransform, ExpTransform
  from pyro.infer.reparam import TransformReparam
  from tests.common import assert_close
  from .util import check_init_reparam
label_desc: Use image node_id 2 for calling a global function with example usage: test_log_normal(batch_shape, event_shape) and returns: pyro