code: def test_sort_epochs_and_values(mode):
      reporter = Reporter()
      key1 = uuid.uuid4().hex
      stats_list = [{"aa": 0.3}, {"aa": 0.5}, {"aa": 0.2}]
      for e in range(len(stats_list)):
          reporter.set_epoch(e + 1)
          with reporter.observe(key1) as sub:
              sub.register(stats_list[e])
              sub.next()
      if mode not in ("min", "max"):
          with pytest.raises(ValueError):
              reporter.sort_epochs_and_values(key1, "aa", mode)
          return
      else:
          sort_values = reporter.sort_epochs_and_values(
              key1, "aa", mode
          )
  
      if mode == "min":
          sign = 1
      else:
          sign = -1
      desired = sorted(
          [
              (e + 1, stats_list[e]["aa"])
              for e in range(len(stats_list))
          ],
          key=lambda x: sign * x[1],
      )
  
      for e in range(len(stats_list)):
          assert sort_values[e] == desired[e]
  
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 2 for calling a global function with example usage: test_sort_epochs_and_values(mode) without return types