code: def test_clamp(shape, min, max):
      tensor = torch.randn(shape)
      if isinstance(min, tuple):
          min = torch.zeros(min)
      if isinstance(max, tuple):
          max = torch.ones(max)
  
      actual = clamp(tensor, min=min, max=max)
  
      expected = tensor
      if min is not None:
          min = torch.as_tensor(min).expand_as(tensor)
          expected = torch.max(min, expected)
      if max is not None:
          max = torch.as_tensor(max).expand_as(tensor)
          expected = torch.min(max, expected)
  
      assert_equal(actual, expected)
  
imports: import pytest
  import torch
  from pyro.contrib.epidemiology.util import cat2, clamp
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_clamp(shape, min, max) without return types