code: def test_enum_recycling_plate(subsampling, reuse_plate, tmc_strategy):
      @infer.config_enumerate(
          default="parallel",
          tmc=tmc_strategy,
          num_samples=2 if tmc_strategy else None,
      )
      def model():
          p = pyro.param("p", torch.ones(3, 3))
          q = pyro.param("q", torch.tensor([0.5, 0.5]))
          plate_x = pyro.plate(
              "plate_x",
              4,
              subsample_size=3 if subsampling else None,
              dim=-1,
          )
          plate_y = pyro.plate(
              "plate_y",
              5,
              subsample_size=3 if subsampling else None,
              dim=-1,
          )
          plate_z = pyro.plate(
              "plate_z",
              6,
              subsample_size=3 if subsampling else None,
              dim=-2,
          )
  
          a = pyro.sample("a", dist.Bernoulli(q[0])).long()
          w = 0
          for i in pyro.markov(range(4)):
              w = pyro.sample("w_{}".format(i), dist.Categorical(p[w]))
  
          with plate_x:
              b = pyro.sample("b", dist.Bernoulli(q[a])).long()
              x = 0
              for i in pyro.markov(range(4)):
                  x = pyro.sample(
                      "x_{}".format(i), dist.Categorical(p[x])
                  )
  
          with plate_y:
              c = pyro.sample("c", dist.Bernoulli(q[a])).long()
              y = 0
              for i in pyro.markov(range(4)):
                  y = pyro.sample(
                      "y_{}".format(i), dist.Categorical(p[y])
                  )
  
          with plate_z:
              d = pyro.sample("d", dist.Bernoulli(q[a])).long()
              z = 0
              for i in pyro.markov(range(4)):
                  z = pyro.sample(
                      "z_{}".format(i), dist.Categorical(p[z])
                  )
  
          with plate_x, plate_z:
              # this part is tricky: how do we know to preserve b's dimension?
              # also, how do we know how to make b and d have different dimensions?
              e = pyro.sample(
                  "e", dist.Bernoulli(q[b if reuse_plate else a])
              ).long()
              xz = 0
              for i in pyro.markov(range(4)):
                  xz = pyro.sample(
                      "xz_{}".format(i), dist.Categorical(p[xz])
                  )
  
          return a, b, c, d, e
  
      assert_ok(model, max_plate_nesting=2)
  
file_path: pyro/tests/contrib/funsor/test_valid_models_plate.py
imports: import logging
  import pytest
  import torch
  from pyro.ops.indexing import Vindex
  from tests.common import xfail_param
label_desc: Use image node_id 3 for calling a global function with example usage: test_enum_recycling_plate(subsampling, reuse_plate, tmc_strategy) and returns: a,  b,  c,  d,  e