code: def test_constraints(constraint, batch_shape, event_shape):
      x = torch.randn(batch_shape + event_shape)
      y = torch.distributions.transform_to(constraint)(x)
      actual = constraint.check(y)
      assert actual.all()
      assert actual.shape == batch_shape
  
imports: import pytest
  import torch
  from pyro.distributions import constraints
  from pyro.ops.tensor_utils import safe_normalize
label_desc: Use image node_id 2 for calling a global function with example usage: test_constraints(constraint, batch_shape, event_shape) without return types