code: def test_log_prob_eval_iterates_in_correct_order():
      @poutine.enum(first_available_dim=-5)
      @config_enumerate
      @poutine.condition(data={"p": torch.tensor(0.4)})
      def model():
          outer = pyro.plate("outer", 3, dim=-1)
          inner1 = pyro.plate("inner1", 4, dim=-3)
          inner2 = pyro.plate("inner2", 5, dim=-2)
          inner3 = pyro.plate("inner3", 6, dim=-4)
  
          p = pyro.sample("p", dist.Uniform(0.0, 1.0))
          y = pyro.sample("y", dist.Bernoulli(p))
          q = 0.5 + 0.25 * y
          with outer, inner2:
              z0 = pyro.sample("z0", dist.Bernoulli(q))
              pyro.sample(
                  "obs0",
                  dist.Normal(2 * z0 - 1, 1.0),
                  obs=torch.ones(5, 3),
              )
          with outer:
              v = pyro.sample("v", dist.Bernoulli(q))
              r = 0.4 + 0.1 * v
              with inner1, inner3:
                  z1 = pyro.sample("z1", dist.Bernoulli(r))
                  pyro.sample(
                      "obs1",
                      dist.Normal(2 * z1 - 1, 1.0),
                      obs=torch.ones(6, 4, 1, 3),
                  )
              with inner2:
                  z2 = pyro.sample("z2", dist.Bernoulli(r))
                  pyro.sample(
                      "obs2",
                      dist.Normal(2 * z2 - 1, 1.0),
                      obs=torch.ones(5, 3),
                  )
  
      model_trace = poutine.trace(model).get_trace()
      trace_prob_evaluator = TraceTreeEvaluator(model_trace, True, 4)
      trace_prob_evaluator.log_prob(model_trace)
      plate_dims, enum_dims = [], []
      for key in reversed(
          sorted(
              trace_prob_evaluator._log_probs.keys(),
              key=lambda x: (len(x), x),
          )
      ):
          plate_dims.append(trace_prob_evaluator._plate_dims[key])
          enum_dims.append(trace_prob_evaluator._enum_dims[key])
      # The reduction operation returns a singleton with dimensions preserved.
      assert not any(
          i != 1
          for i in trace_prob_evaluator._aggregate_log_probs(
              frozenset()
          ).shape
      )
      assert plate_dims == [[-4, -3], [-2], [-1], []]
      assert enum_dims, [[-8], [-9, -6], [-7], [-5]]
  
imports: import io
  import logging
  import pytest
  import torch
  import pyro
  import pyro.distributions
  import pyro.poutine
  from pyro.infer import config_enumerate
  from pyro.infer.mcmc import HMC, NUTS
  from pyro.infer.mcmc.api import MCMC
  from pyro.infer.mcmc.util import TraceEinsumEvaluator, TraceTreeEvaluator, initialize_model
  from pyro.infer.reparam import LatentStableReparam
  from pyro.poutine.subsample_messenger import _Subsample
  from tests.common import assert_close, assert_equal, xfail_param
label_desc: Use image node_id 6 for calling a global function with example usage: test_log_prob_eval_iterates_in_correct_order() without return types