code: def test_safe_log():
      # Test values.
      x = torch.randn(1000).exp().requires_grad_()
      expected = x.log()
      actual = safe_log(x)
      assert_equal(actual, expected)
      assert_equal(
          grad(actual.sum(), [x])[0], grad(expected.sum(), [x])[0]
      )
  
      # Test gradients.
      x = torch.tensor(0.0, requires_grad=True)
      assert not torch.isfinite(grad(x.log(), [x])[0])
      assert torch.isfinite(grad(safe_log(x), [x])[0])
  
file_path: pyro/tests/ops/test_special.py
imports: import pytest
  import torch
  from scipy.special import iv
  from torch import tensor
  from torch.autograd import grad
  from pyro.ops.special import get_quad_rule, log_beta, log_binomial, log_I1, safe_log
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_safe_log() without return types