code: def test_enum_recycling_grid(grid_size, use_vindex):
      #  x---x---x---x    -----> i
      #  |   |   |   |   |
      #  x---x---x---x   |
      #  |   |   |   |   V
      #  x---x---x--(x)  j
      #  |   |   |   |
      #  x---x--(x)--x <-- what can this depend on?
  
      @infer.config_enumerate
      def model():
          p = pyro.param("p_leaf", torch.ones(2, 2, 2))
          x = defaultdict(lambda: torch.tensor(0))
          y_axis = pyro.markov(range(grid_size), keep=True)
          for i in pyro.markov(range(grid_size)):
              for j in y_axis:
                  if use_vindex:
                      probs = Vindex(p)[x[i - 1, j], x[i, j - 1]]
                  else:
                      ind = torch.arange(2, dtype=torch.long)
                      probs = p[
                          x[i - 1, j].unsqueeze(-1),
                          x[i, j - 1].unsqueeze(-1),
                          ind,
                      ]
                  x[i, j] = pyro.sample(
                      "x_{}_{}".format(i, j), dist.Categorical(probs)
                  )
  
      assert_ok(model, max_plate_nesting=0)
  
imports: import contextlib
  import logging
  import os
  from collections import defaultdict
  from queue import LifoQueue
  import pytest
  import torch
  from pyro.infer.enum import iter_discrete_escape, iter_discrete_extend
  from pyro.ops.indexing import Vindex
  from pyro.poutine import Trace
  from pyro.poutine.util import prune_subsample_sites
  from pyro.util import check_traceenum_requirements
label_desc: Use image node_id 9 for calling a global function with example usage: test_enum_recycling_grid(grid_size, use_vindex) without return types