code: def test_elbo_enumerate_plate_9():
      #        Model   Guide
      #          a
      #  +-------|-------+
      #  | M=2   V       |
      #  |       b -> c  |
      #  +---------------+
      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([1, 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")
          a = pyro.sample("a", dist.Categorical(probs_a))
          with pyro.plate("b_axis", 2):
              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")
          a = pyro.sample("a", dist.Categorical(probs_a))
          with pyro.plate("b_axis", 2):
              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")
          a = pyro.sample("a", dist.Categorical(probs_a))
          for i in pyro.plate("b_axis", 2):
              b = pyro.sample(f"b_{i}", dist.Categorical(probs_b[a]))
              pyro.sample(
                  f"c_{i}", dist.Categorical(probs_c[b]), obs=data[i]
              )
  
      @infer.config_enumerate
      def guide_iplate():
          probs_a = pyro.param("guide_probs_a")
          probs_b = pyro.param("guide_probs_b")
          a = pyro.sample("a", dist.Categorical(probs_a))
          for i in pyro.plate("b_axis", 2):
              pyro.sample(f"b_{i}", 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=1)
      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 21 for calling a global function with example usage: test_elbo_enumerate_plate_9() without return types