code: def test_elbo_enumerate_plates_1(scale):
      #  +-----------------+
      #  | a ----> b   M=2 |
      #  +-----------------+
      #  +-----------------+
      #  | c ----> d   N=3 |
      #  +-----------------+
      # This tests two unrelated plates.
      # Each should remain uncontracted.
      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.75, 0.25]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "probs_d",
          torch.tensor([[0.4, 0.6], [0.3, 0.7]]),
          constraint=constraints.simplex,
      )
      b_data = torch.tensor([0, 1])
      d_data = torch.tensor([0, 0, 1])
  
      @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")
          probs_d = pyro.param("probs_d")
          with pyro.plate("a_axis", 2):
              a = pyro.sample("a", dist.Categorical(probs_a))
              pyro.sample("b", dist.Categorical(probs_b[a]), obs=b_data)
          with pyro.plate("c_axis", 3):
              c = pyro.sample("c", dist.Categorical(probs_c))
              pyro.sample("d", dist.Categorical(probs_d[c]), obs=d_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")
          probs_d = pyro.param("probs_d")
          for i in pyro.plate("a_axis", 2):
              a = pyro.sample(
                  "a_{}".format(i), dist.Categorical(probs_a)
              )
              pyro.sample(
                  "b_{}".format(i),
                  dist.Categorical(probs_b[a]),
                  obs=b_data[i],
              )
          for j in pyro.plate("c_axis", 3):
              c = pyro.sample(
                  "c_{}".format(j), dist.Categorical(probs_c)
              )
              pyro.sample(
                  "d_{}".format(j),
                  dist.Categorical(probs_d[c]),
                  obs=d_data[j],
              )
  
      def guide():
          pass
  
      elbo = infer.TraceEnum_ELBO(max_plate_nesting=1)
      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 13 for calling a global function with example usage: test_elbo_enumerate_plates_1(scale) without return types