code: def test_invalid_ssim():
      y_pred = torch.rand(1, 1, 4, 4)
      y = y_pred + 0.125
      with pytest.raises(
          ValueError,
          match=r"Expected kernel_size to have odd positive number.",
      ):
          ssim = SSIM(data_range=1.0, kernel_size=2)
          ssim.update((y_pred, y))
          ssim.compute()
  
      with pytest.raises(
          ValueError,
          match=r"Expected kernel_size to have odd positive number.",
      ):
          ssim = SSIM(data_range=1.0, kernel_size=-1)
          ssim.update((y_pred, y))
          ssim.compute()
  
      with pytest.raises(
          ValueError,
          match=r"Argument kernel_size should be either int or a sequence of int.",
      ):
          ssim = SSIM(data_range=1.0, kernel_size=1.0)
          ssim.update((y_pred, y))
          ssim.compute()
  
      with pytest.raises(
          ValueError,
          match=r"Argument sigma should be either float or a sequence of float.",
      ):
          ssim = SSIM(data_range=1.0, sigma=-1)
          ssim.update((y_pred, y))
          ssim.compute()
  
      with pytest.raises(
          ValueError, match=r"Expected sigma to have positive number."
      ):
          ssim = SSIM(data_range=1.0, sigma=(-1, -1))
          ssim.update((y_pred, y))
          ssim.compute()
  
      with pytest.raises(
          ValueError,
          match=r"Argument sigma should be either float or a sequence of float.",
      ):
          ssim = SSIM(data_range=1.0, sigma=1)
          ssim.update((y_pred, y))
          ssim.compute()
  
      with pytest.raises(
          ValueError,
          match=r"Expected y_pred and y to have the same shape.",
      ):
          y = y.squeeze(dim=0)
          ssim = SSIM(data_range=1.0)
          ssim.update((y_pred, y))
          ssim.compute()
  
      with pytest.raises(
          ValueError,
          match=r"Expected y_pred and y to have BxCxHxW shape.",
      ):
          y = y.squeeze(dim=0)
          ssim = SSIM(data_range=1.0)
          ssim.update((y, y))
          ssim.compute()
  
      with pytest.raises(
          TypeError,
          match=r"Expected y_pred and y to have the same data type.",
      ):
          y = y.double()
          ssim = SSIM(data_range=1.0)
          ssim.update((y_pred, y))
          ssim.compute()
  
file_path: ignite/tests/ignite/metrics/test_ssim.py
imports: from typing import Sequence, Union
  import numpy
  import pytest
  import torch
  from skimage.metrics import structural_similarity
  import ignite.distributed
  from ignite.exceptions import NotComputableError
  from ignite.metrics import SSIM
label_desc: Use image node_id 2 for calling a global function with example usage: test_invalid_ssim() without return types