code: def test_elbo_enumerate_3(scale):
      pyro.param(
          "guide_probs_x",
          torch.tensor([0.1, 0.9]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "model_probs_x",
          torch.tensor([0.4, 0.6]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "model_probs_y",
          torch.tensor([[0.75, 0.25], [0.55, 0.45]]),
          constraint=constraints.simplex,
      )
      pyro.param(
          "model_probs_z",
          torch.tensor([[0.3, 0.7], [0.2, 0.8]]),
          constraint=constraints.simplex,
      )
  
      def auto_model():
          probs_x = pyro.param("model_probs_x")
          probs_y = pyro.param("model_probs_y")
          probs_z = pyro.param("model_probs_z")
          x = pyro.sample("x", dist.Categorical(probs_x))
          with handlers.scale(scale=scale):
              y = pyro.sample(
                  "y",
                  dist.Categorical(probs_y[x]),
                  infer={"enumerate": "parallel"},
              )
              pyro.sample(
                  "z", dist.Categorical(probs_z[y]), obs=torch.tensor(0)
              )
  
      def hand_model():
          probs_x = pyro.param("model_probs_x")
          probs_y = pyro.param("model_probs_y")
          probs_z = pyro.param("model_probs_z")
          probs_yz = probs_y.mm(probs_z)
          x = pyro.sample("x", dist.Categorical(probs_x))
          with handlers.scale(scale=scale):
              pyro.sample(
                  "z",
                  dist.Categorical(probs_yz[x]),
                  obs=torch.tensor(0),
              )
  
      @infer.config_enumerate
      def guide():
          probs_x = pyro.param("guide_probs_x")
          pyro.sample("x", dist.Categorical(probs_x))
  
      elbo = infer.TraceEnum_ELBO(max_plate_nesting=0)
      auto_loss = elbo.differentiable_loss(auto_model, guide)
      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 5 for calling a global function with example usage: test_elbo_enumerate_3(scale) without return types