code: def test_error_on_different_shape(metric_class=SpectralAngleMapper):
      """Test that error is raised if preds and target have different shape."""
      metric = metric_class()
      with pytest.raises(
          RuntimeError,
          match="Predictions and targets are expected to have the same shape.*",
      ):
          metric(
              torch.randn([1, 3, 16, 16]), torch.randn([1, 1, 16, 16])
          )
  
imports: from functools import partial
  import pytest
  import torch
  from torch import Tensor
  from torch.nn import functional
  from torchmetrics.functional.image.sam import spectral_angle_mapper
  from torchmetrics.image.sam import SpectralAngleMapper
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_2_1
  from unittests import BATCH_SIZE, NUM_BATCHES, _Input
  from unittests.helpers import seed_all
  from unittests.helpers.testers import MetricTester
label_desc: Use image node_id 2 for calling a global function with example usage: test_error_on_different_shape(metric_class) without return types