code: def assert_ok(model, guide=None, max_plate_nesting=None, **kwargs):
      """
      Assert that enumeration runs...
      """
      with pyro_backend("pyro"):
          pyro.clear_param_store()
  
      if guide is None:
          guide = lambda **kwargs: None  # noqa: E731
  
      q_pyro, q_funsor = LifoQueue(), LifoQueue()
      q_pyro.put(Trace())
      q_funsor.put(Trace())
  
      while not q_pyro.empty() and not q_funsor.empty():
          with pyro_backend("pyro"):
              with handlers.enum(
                  first_available_dim=-max_plate_nesting - 1
              ):
                  guide_tr_pyro = handlers.trace(
                      handlers.queue(
                          guide,
                          q_pyro,
                          escape_fn=iter_discrete_escape,
                          extend_fn=iter_discrete_extend,
                      )
                  ).get_trace(**kwargs)
                  tr_pyro = handlers.trace(
                      handlers.replay(model, trace=guide_tr_pyro)
                  ).get_trace(**kwargs)
  
          with pyro_backend("contrib.funsor"):
              with handlers.enum(
                  first_available_dim=-max_plate_nesting - 1
              ):
                  guide_tr_funsor = handlers.trace(
                      handlers.queue(
                          guide,
                          q_funsor,
                          escape_fn=iter_discrete_escape,
                          extend_fn=iter_discrete_extend,
                      )
                  ).get_trace(**kwargs)
                  tr_funsor = handlers.trace(
                      handlers.replay(model, trace=guide_tr_funsor)
                  ).get_trace(**kwargs)
  
          # make sure all dimensions were cleaned up
          assert _DIM_STACK.local_frame is _DIM_STACK.global_frame
          assert (
              not _DIM_STACK.global_frame.name_to_dim
              and not _DIM_STACK.global_frame.dim_to_name
          )
          assert _DIM_STACK.outermost is None
  
          tr_pyro = prune_subsample_sites(tr_pyro.copy())
          tr_funsor = prune_subsample_sites(tr_funsor.copy())
          _check_traces(tr_pyro, tr_funsor)
  
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 1 for calling a global function with example usage: assert_ok(model, guide, max_plate_nesting) without return types