code: def test_elbo_enumerate_plate_11():
      # Model
      # [ ai -> [ bij -> cij ] ]
      # Guide
      # [ ai -> [ bij ] ]
      pyro.param(
          "model_probs_a",
          torch.tensor([0.45, 0.55]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "model_probs_b",
          torch.tensor([[0.3, 0.7], [0.6, 0.4]]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "model_probs_c",
          torch.tensor([[0.3, 0.4, 0.3], [0.4, 0.4, 0.2]]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "guide_probs_a",
          torch.tensor([0.45, 0.55]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "guide_probs_b",
          torch.tensor([[0.3, 0.7], [0.8, 0.2]]),
          constraint=constraints.simplex,
      )
      data = torch.tensor([[0, 1, 2], [1, 2, 2]])
  
      @infer.config_enumerate
      def model_plate():
          probs_a = pyro.param("model_probs_a")
          probs_b = pyro.param("model_probs_b")
          probs_c = pyro.param("model_probs_c")
          with pyro.plate("i", 2, dim=-2):
              a = pyro.sample("a", dist.Categorical(probs_a))
              with pyro.plate("j", 3, dim=-1):
                  b = pyro.sample("b", dist.Categorical(probs_b[a]))
                  pyro.sample(
                      "c", dist.Categorical(probs_c[b]), obs=data
                  )
  
      @infer.config_enumerate
      def guide_plate():
          probs_a = pyro.param("guide_probs_a")
          probs_b = pyro.param("guide_probs_b")
          with pyro.plate("i", 2, dim=-2):
              a = pyro.sample("a", dist.Categorical(probs_a))
              with pyro.plate("j", 3, dim=-1):
                  pyro.sample("b", dist.Categorical(probs_b[a]))
  
      @infer.config_enumerate
      def model_iplate():
          probs_a = pyro.param("model_probs_a")
          probs_b = pyro.param("model_probs_b")
          probs_c = pyro.param("model_probs_c")
          for i in pyro.plate("i", 2):
              a = pyro.sample(f"a_{i}", dist.Categorical(probs_a))
              for j in pyro.plate("j", 3):
                  b = pyro.sample(
                      f"b_{i}_{j}", dist.Categorical(probs_b[a])
                  )
                  pyro.sample(
                      f"c_{i}_{j}",
                      dist.Categorical(probs_c[b]),
                      obs=data[i, j],
                  )
  
      @infer.config_enumerate
      def guide_iplate():
          probs_a = pyro.param("guide_probs_a")
          probs_b = pyro.param("guide_probs_b")
          for i in pyro.plate("i", 2):
              a = pyro.sample(f"a_{i}", dist.Categorical(probs_a))
              for j in pyro.plate("j", 3):
                  pyro.sample(
                      f"b_{i}_{j}", dist.Categorical(probs_b[a])
                  )
  
      elbo = infer.TraceEnum_ELBO(max_plate_nesting=0)
      expected_loss = elbo.differentiable_loss(
          model_iplate, guide_iplate
      )
      elbo = infer.TraceEnum_ELBO(max_plate_nesting=2)
      actual_loss = elbo.differentiable_loss(model_plate, guide_plate)
      _check_loss_and_grads(expected_loss, actual_loss)
  
imports: import logging
  import os
  import pyroapi
  import pytest
  import torch
  from torch.autograd import grad
  from torch.distributions import constraints
  from pyro.ops.indexing import Vindex
  from pyro.util import torch_isnan
  from tests.common import assert_equal, xfail_param
label_desc: Use image node_id 23 for calling a global function with example usage: test_elbo_enumerate_plate_11() without return types