code: def test_enum_recycling_dbn(markov, use_vindex):
      #    x --> x --> x  enum "state"
      # y  |  y  |  y  |  enum "occlusion"
      #  \ |   \ |   \ |
      #    z     z     z  obs
  
      @infer.config_enumerate
      def model():
          p = pyro.param("p", torch.ones(3, 3))
          q = pyro.param("q", torch.ones(2))
          r = pyro.param("r", torch.ones(3, 2, 4))
  
          x = 0
          times = pyro.markov(range(100)) if markov else range(11)
          for t in times:
              x = pyro.sample("x_{}".format(t), dist.Categorical(p[x]))
              y = pyro.sample("y_{}".format(t), dist.Categorical(q))
              if use_vindex:
                  probs = Vindex(r)[x, y]
              else:
                  z_ind = torch.arange(4, dtype=torch.long)
                  probs = r[x.unsqueeze(-1), y.unsqueeze(-1), z_ind]
              pyro.sample(
                  "z_{}".format(t),
                  dist.Categorical(probs),
                  obs=torch.tensor(0.0),
              )
  
      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 7 for calling a global function with example usage: test_enum_recycling_dbn(markov, use_vindex) without return types