code: def elbo_infer_discrete(model, first_available_dim, temperature):
      """
      Wrapper around ``TraceEnumSample_ELBO`` to test agreement with
      ``TraceEnum_ELBO`` and then return ``.sample_saved()``.
      """
      assert temperature == 1
      max_plate_nesting = -first_available_dim - 1
      expected_elbo = TraceEnum_ELBO(
          max_plate_nesting=max_plate_nesting
      )
      actual_elbo = TraceEnumSample_ELBO(
          max_plate_nesting=max_plate_nesting
      )
  
      def empty_guide(*args, **kwargs):
          pass
  
      def inferred_model(*args, **kwargs):
          with poutine.block():
              expected_loss = expected_elbo.loss(
                  model, empty_guide, *args, **kwargs
              )
              actual_loss = actual_elbo.loss(
                  model, empty_guide, *args, **kwargs
              )
          assert_equal(actual_loss, expected_loss)
          return actual_elbo.sample_saved()
  
      return inferred_model
  
imports: import logging
  import math
  import warnings
  import pytest
  import torch
  from torch.autograd import grad
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer import TraceEnum_ELBO
  from pyro.infer.discrete import TraceEnumSample_ELBO, infer_discrete
  from pyro.infer.enum import config_enumerate
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: elbo_infer_discrete(model, first_available_dim, temperature) and returns: inferred_model, actual_elbo