code: def compute_elbo_grad(model, guide, variables):
      x = guide.rsample()
      model_log_prob = model.log_prob(x)
      guide_log_prob, score_function, entropy_term = guide.score_parts(
          x
      )
      log_r = model_log_prob - guide_log_prob
      surrogate_elbo = (
          model_log_prob
          + log_r.detach() * score_function
          - entropy_term
      )
      return grad(surrogate_elbo.sum(), variables, create_graph=True)
  
file_path: pyro/tests/distributions/test_rejector.py
imports: import pytest
  import torch
  from torch.autograd import grad
  from pyro.distributions import Exponential, Gamma
  from pyro.distributions.testing.rejection_exponential import RejectionExponential
  from pyro.distributions.testing.rejection_gamma import RejectionGamma, RejectionStandardGamma, ShapeAugmentedBeta, ShapeAugmentedGamma
  from tests.common import assert_equal
label_desc: Use image node_id 3 for calling a global function with example usage: compute_elbo_grad(model, guide, variables) and returns: grad