code: def test_get_int_dtype():
      uint8 = np.dtype(np.uint8)
      uint16 = np.dtype(np.uint16)
      uint32 = np.dtype(np.uint32)
      uint64 = np.dtype(np.uint64)
      # signed
      cur = np.iinfo(np.int8)
      for val in [cur.min, cur.min + 1, -1, 0, 1, cur.max - 1, cur.max]:
          assert _get_int_dtype(val) == np.int8
          assert _get_int_dtype(val, signed=True) == np.int8
          if val >= 0:
              assert _get_int_dtype(val, unsigned=True) == np.uint8
              assert _get_int_dtype(val + 1, unsigned=True) == np.uint8
      prev = cur
      cur = np.iinfo(np.int16)
      for val in [
          cur.min,
          cur.min + 1,
          prev.min - 1,
          prev.max + 1,
          cur.max - 1,
          cur.max,
      ]:
          assert _get_int_dtype(val) != prev.dtype
          assert _get_int_dtype(val, signed=True) == np.int16
          if val >= 0:
              assert _get_int_dtype(val, unsigned=True) in {
                  uint8,
                  uint16,
              }
              assert _get_int_dtype(val + 1, unsigned=True) in {
                  uint8,
                  uint16,
              }
      prev = cur
      cur = np.iinfo(np.int32)
      for val in [
          cur.min,
          cur.min + 1,
          prev.min - 1,
          prev.max + 1,
          cur.max - 1,
          cur.max,
      ]:
          assert _get_int_dtype(val) != prev.dtype
          assert _get_int_dtype(val, signed=True) == np.int32
          if val >= 0:
              assert _get_int_dtype(val, unsigned=True) in {
                  uint16,
                  uint32,
              }
              assert _get_int_dtype(val + 1, unsigned=True) in {
                  uint16,
                  uint32,
              }
      prev = cur
      cur = np.iinfo(np.int64)
      for val in [
          cur.min,
          cur.min + 1,
          prev.min - 1,
          prev.max + 1,
          cur.max - 1,
          cur.max,
      ]:
          assert _get_int_dtype(val) != prev.dtype
          assert _get_int_dtype(val, signed=True) == np.int64
          if val >= 0:
              assert _get_int_dtype(val, unsigned=True) in {
                  uint32,
                  uint64,
              }
              assert _get_int_dtype(val + 1, unsigned=True) in {
                  uint32,
                  uint64,
              }
      with pytest.raises(ValueError, match="Value is too"):
          _get_int_dtype(cur.min - 1, signed=True)
      with pytest.raises(ValueError, match="Value is too"):
          _get_int_dtype(cur.max + 1, signed=True)
  
      # unsigned
      cur = np.iinfo(np.uint8)
      for val in [0, 1, cur.max - 1, cur.max]:
          assert _get_int_dtype(val) == (
              np.uint8 if val > 1 else np.int8
          )
          assert _get_int_dtype(val, unsigned=True) == np.uint8
      assert _get_int_dtype(cur.max + 1) == np.int16
      cur = np.iinfo(np.uint16)
      for val in [cur.max - 1, cur.max]:
          assert _get_int_dtype(val, unsigned=True) == np.uint16
      assert _get_int_dtype(cur.max + 1) == np.int32
      cur = np.iinfo(np.uint32)
      for val in [cur.max - 1, cur.max]:
          assert _get_int_dtype(val, unsigned=True) == np.uint32
      assert _get_int_dtype(cur.max + 1) == np.int64
      cur = np.iinfo(np.uint64)
      for val in [cur.max - 1, cur.max]:
          assert _get_int_dtype(val, unsigned=True) == np.uint64
      with pytest.raises(ValueError, match="Value is incompatible"):
          _get_int_dtype(cur.min - 1, unsigned=True)
      with pytest.raises(ValueError, match="Value is too"):
          _get_int_dtype(cur.max + 1, unsigned=True)
  
      # API
      with pytest.raises(TypeError, match="incompatible"):
          _get_int_dtype(7, signed=True, unsigned=True)
      assert _get_int_dtype(7, signed=True, unsigned=False) == np.int8
      assert _get_int_dtype(7, signed=False, unsigned=True) == np.uint8
  
label_desc: Use image node_id 1 for calling a global function with example usage: test_get_int_dtype() without return types