code: def test_error_on_different_shape(metric_class=CosineSimilarity):
      """Test that error is raised on different shapes of input."""
      metric = metric_class()
      with pytest.raises(
          RuntimeError,
          match="Predictions and targets are expected to have the same shape",
      ):
          metric(torch.randn(100, 2), torch.randn(50, 2))
  
file_path: torchmetrics/tests/unittests/regression/test_cosine_similarity.py
imports: from functools import partial
  import numpy
  import pytest
  import torch
  from sklearn.metrics.pairwise import cosine_similarity
  from torchmetrics.functional.regression.cosine_similarity import cosine_similarity
  from torchmetrics.regression.cosine_similarity import CosineSimilarity
  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