code: def _test_inverse(self, shape, transform):
      # Test g^{-1}(g(x)) = x
      # NOTE: Calling _call and _inverse directly bypasses caching
      base_dist = dist.Normal(torch.zeros(shape), torch.ones(shape))
      x_true = base_dist.sample(torch.Size([10]))
      y = transform._call(x_true)
      x_calculated = transform._inverse(y)
      if transform.bijective:
          assert (x_true - x_calculated).abs().max().item() < self.delta
      else:
          # Check the weaker pseudoinverse equation.
          y2 = transform._call(x_calculated)
          assert (y - y2).abs().max().item() < self.delta
  
      if transform.bijective:
          # Test that Jacobian after inverse op is same as after forward
          J_1 = transform.log_abs_det_jacobian(x_true, y)
          J_2 = transform.log_abs_det_jacobian(x_calculated, y)
          assert (J_1 - J_2).abs().max().item() < self.delta
  
imports: import operator
  from functools import partial, reduce
  from unittest import TestCase
  import pytest
  import torch
  import pyro.distributions
  import pyro.distributions.transforms
  from pyro.distributions import constraints
  from tests.common import assert_close
label_desc: Use image node_id 3 for calling the TransformTests obj's underlying member method code with example usage: obj._test_inverse(shape, transform) without return types