code: def test_warning_on_compute_before_update():
      """Test that an warning is raised if user tries to call compute before update."""
      metric = DummyMetricSum()
  
      # make sure everything is fine with forward
      with pytest.warns(None) as record:
          val = metric(1)
      assert not record
  
      metric.reset()
  
      with pytest.warns(
          UserWarning, match=r"The ``compute`` method of metric .*"
      ):
          val = metric.compute()
      assert val == 0.0
  
      # after update things should be fine
      metric.update(2.0)
      with pytest.warns(None) as record:
          val = metric.compute()
      assert not record
      assert val == 2.0
  
imports: import os
  import pickle
  from collections import OrderedDict
  from typing import Any
  from unittest.mock import Mock
  import cloudpickle
  import numpy
  import psutil
  import pytest
  import torch
  from torch import Tensor, tensor
  from torch.nn import Module, Parameter
  from torchmetrics.classification import BinaryAccuracy
  from torchmetrics.regression import PearsonCorrCoef
  from unittests.helpers import seed_all
  from unittests.helpers.testers import DummyListMetric, DummyMetric, DummyMetricMultiOutput, DummyMetricSum
  from unittests.helpers.utilities import no_warning_call
label_desc: Use image node_id 18 for calling a global function with example usage: test_warning_on_compute_before_update() without return types