code: def test_error_on_different_shape():
      """Test that error is raised on different shapes of input."""
      metric = KLDivergence()
      with pytest.raises(
          RuntimeError,
          match="Predictions and targets are expected to have the same shape",
      ):
          metric(torch.randn(100), torch.randn(50))
  
imports: from functools import partial
  from typing import NamedTuple, Optional
  import numpy
  import pytest
  import torch
  from scipy.stats import entropy
  from torch import Tensor
  from torchmetrics.functional.regression.kl_divergence import kl_divergence
  from torchmetrics.regression.kl_divergence import KLDivergence
  from torchmetrics.utilities.imports import _TORCH_GREATER_EQUAL_2_1
  from unittests import BATCH_SIZE, EXTRA_DIM, NUM_BATCHES
  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() without return types