code: def test_register(weight1, weight2):
      reporter = Reporter()
      reporter.set_epoch(1)
      with reporter.observe(uuid.uuid4().hex) as sub:
          stats1 = {
              "float": 0.6,
              "int": 6,
              "np": np.random.random(),
              "torch": torch.rand(1),
          }
          sub.register(stats1, weight1)
          sub.next()
  
          stats2 = {
              "float": 0.3,
              "int": 100,
              "np": np.random.random(),
              "torch": torch.rand(1),
          }
          sub.register(stats2, weight2)
          sub.next()
          assert sub.get_epoch() == 1
      with pytest.raises(RuntimeError):
          sub.register({})
  
      desired = {}
      for k in stats1:
          if stats1[k] is None:
              continue
  
          if weight1 is None:
              desired[k] = (stats1[k] + stats2[k]) / 2
          else:
              weight1 = float(weight1)
              weight2 = float(weight2)
              desired[k] = float(
                  weight1 * stats1[k] + weight2 * stats2[k]
              )
              desired[k] /= weight1 + weight2
  
      for k1, k2 in reporter.get_all_keys():
          if k2 in (
              "time",
              "total_count",
              "gpu_max_cached_mem_GB",
              "gpu_cached_mem_GB",
          ):
              continue
          np.testing.assert_allclose(
              reporter.get_value(k1, k2), desired[k2]
          )
  
imports: import logging
  import uuid
  from pathlib import Path
  import numpy
  import pytest
  import torch
  from torch.utils.tensorboard import SummaryWriter
  from espnet2.train.reporter import Average, ReportedValue, Reporter, aggregate
label_desc: Use image node_id 1 for calling a global function with example usage: test_register(weight1, weight2) without return types