code: def test_tracker(base_metric, metric_input, maximize):
      """Test that arguments gets passed correctly to child modules."""
      tracker = MetricTracker(base_metric, maximize=maximize)
      for i in range(5):
          tracker.increment()
          # check both update and forward works
          for _ in range(5):
              tracker.update(*metric_input)
          for _ in range(5):
              tracker(*metric_input)
  
          # Make sure we have computed something
          val = tracker.compute()
          if isinstance(val, dict):
              for v in val.values():
                  assert v != 0.0
          else:
              assert val != 0.0
          assert tracker.n_steps == i + 1
  
      # Assert that compute all returns all values
      assert tracker.n_steps == 5
      all_computed_val = tracker.compute_all()
      if isinstance(all_computed_val, dict):
          for v in all_computed_val.values():
              assert v.numel() == 5
      else:
          assert all_computed_val.numel() == 5
  
      # Assert that best_metric returns both index and value
      val, idx = tracker.best_metric(return_step=True)
      if isinstance(val, dict):
          for v, i in zip(val.values(), idx.values()):
              assert v != 0.0
              assert i in list(range(5))
      else:
          assert val != 0.0
          assert idx in list(range(5))
  
      val2 = tracker.best_metric(return_step=False)
      assert val == val2
  
file_path: torchmetrics/tests/unittests/wrappers/test_tracker.py
imports: import pytest
  import torch
  from torchmetrics import MetricCollection
  from torchmetrics.classification import MulticlassAccuracy, MulticlassConfusionMatrix, MulticlassPrecision, MulticlassRecall
  from torchmetrics.regression import MeanAbsoluteError, MeanSquaredError
  from torchmetrics.wrappers import MetricTracker, MultioutputWrapper
  from unittests.helpers import seed_all
label_desc: Use image node_id 3 for calling a global function with example usage: test_tracker(base_metric, metric_input, maximize) without return types