code: def test_error_on_grayscale_image(metric_class=SpectralAngleMapper):
      """Test that error is raised if number of channels is not larger than 1."""
      metric = metric_class()
      with pytest.raises(
          ValueError,
          match="Expected channel dimension of `preds` and `target` to be larger than 1.*",
      ):
          metric(
              torch.randn([16, 1, 16, 16]), torch.randn([16, 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 5 for calling a global function with example usage: test_error_on_grayscale_image(metric_class) without return types