code: def test_elbo_enumerate_plates_5(scale):
      #     a
      #     | \
      #  +--|---\------------+
      #  |  V   +-\--------+ |
      #  |  b ----> c      | |
      #  |      |      N=2 | |
      #  | M=2  +----------+ |
      #  +-------------------+
      pyro.param(
          "probs_a",
          torch.tensor([0.45, 0.55]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "probs_b",
          torch.tensor([[0.6, 0.4], [0.4, 0.6]]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "probs_c",
          torch.tensor(
              [[[0.4, 0.6], [0.3, 0.7]], [[0.2, 0.8], [0.1, 0.9]]]
          ),
          constraint=constraints.simplex,
      )
      data = torch.tensor([[0, 1], [0, 0]])
  
      @infer.config_enumerate
      @handlers.scale(scale=scale)
      def auto_model():
          probs_a = pyro.param("probs_a")
          probs_b = pyro.param("probs_b")
          probs_c = pyro.param("probs_c")
          a = pyro.sample("a", dist.Categorical(probs_a))
          with pyro.plate("outer", 2):
              b = pyro.sample("b", dist.Categorical(probs_b[a]))
              with pyro.plate("inner", 2):
                  pyro.sample(
                      "c",
                      dist.Categorical(Vindex(probs_c)[a, b]),
                      obs=data,
                  )
  
      @infer.config_enumerate
      @handlers.scale(scale=scale)
      def hand_model():
          probs_a = pyro.param("probs_a")
          probs_b = pyro.param("probs_b")
          probs_c = pyro.param("probs_c")
          inner = pyro.plate("inner", 2)
          a = pyro.sample("a", dist.Categorical(probs_a))
          for i in pyro.plate("outer", 2):
              b = pyro.sample(
                  "b_{}".format(i), dist.Categorical(probs_b[a])
              )
              for j in inner:
                  pyro.sample(
                      "c_{}_{}".format(i, j),
                      dist.Categorical(Vindex(probs_c)[a, b]),
                      obs=data[i, j],
                  )
  
      def guide():
          pass
  
      elbo = infer.TraceEnum_ELBO(max_plate_nesting=2)
      auto_loss = elbo.differentiable_loss(auto_model, guide)
      elbo = infer.TraceEnum_ELBO(max_plate_nesting=0)
      hand_loss = elbo.differentiable_loss(hand_model, guide)
      _check_loss_and_grads(hand_loss, auto_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 17 for calling a global function with example usage: test_elbo_enumerate_plates_5(scale) without return types