code: def test_biject_to(constraint_fn, args, is_cuda):
      constraint = build_constraint(
          constraint_fn, args, is_cuda=is_cuda
      )
      try:
          t = biject_to(constraint)
      except NotImplementedError:
          pytest.skip("`biject_to` not implemented.")
      assert t.bijective, f"biject_to({constraint}) is not bijective"
      if constraint_fn is constraints.corr_cholesky:
          # (D * (D-1)) / 2 (where D = 4) = 6 (size of last dim)
          x = torch.randn(6, 6, dtype=torch.double)
      else:
          x = torch.randn(5, 5, dtype=torch.double)
      if is_cuda:
          x = x.cuda()
      y = t(x)
      assert constraint.check(y).all(), "\n".join(
          [
              f"Failed to biject_to({constraint})",
              f"x = {x}",
              f"biject_to(...)(x) = {y}",
          ]
      )
      x2 = t.inv(y)
      assert torch.allclose(
          x, x2
      ), f"Error in biject_to({constraint}) inverse"
  
      j = t.log_abs_det_jacobian(x, y)
      assert j.shape == x.shape[: x.dim() - t.domain.event_dim]
  
file_path: pytorch/test/distributions/test_constraints.py
imports: import pytest
  import torch
  from torch.distributions import biject_to, constraints, transform_to
  from torch.testing._internal.common_cuda import TEST_CUDA
  from torch.testing._internal.common_utils import run_tests
label_desc: Use image node_id 3 for calling a global function with example usage: test_biject_to(constraint_fn, args, is_cuda) without return types