code: def test_multistream_amca_two_task_dynamic(self):
      metric = MultiStreamAMCA()
      self.assertEqual(metric.result(), {})
  
      my_y = torch.as_tensor([0, 0, 1, 0, 2, 2, 0])
      my_out = torch.as_tensor([0, 0, 1, 2, 1, 1, 1])
      my_amca = (0.5 + 1.0 + 0.0) / 3
      # 0: 50%, 1: 100%, 2: 0%
  
      my_y2 = torch.as_tensor([0, 0, 1, 0, 2, 2, 0])
      my_out2 = torch.as_tensor([2, 2, 2, 2, 1, 2, 1])
      my_amca2 = (0.0 + 0.0 + 0.5) / 3
      # 0: 0%, 1: 0%, 2: 50%
  
      with self.assertRaises(RuntimeError):
          # Should call next_experience first
          metric.update(my_out, my_y, 0)
  
      metric.set_stream("test")
      metric.update(my_out, my_y, 0)
      self.assertDictEqual(metric.result(), {"test": {0: my_amca}})
  
      metric.reset()
      # After reset, previously dynamically added tasks are remembered
      self.assertDictEqual(metric.result(), {"test": {0: 0.0}})
  
      with self.assertRaises(RuntimeError):
          # Again, should call next_experience first, even after reset
          metric.update(my_out, my_y, 0)
  
      metric.set_stream("test")
      metric.update(my_out, my_y, 0)
      self.assertDictEqual(metric.result(), {"test": {0: my_amca}})
  
      metric.set_stream("train")
      self.assertDictEqual(
          metric.result(), {"test": {0: my_amca}, "train": {}}
      )
  
      metric.update(my_out2, my_y2, 1)
      self.assertDictEqual(
          metric.result(),
          {"test": {0: my_amca}, "train": {1: my_amca2}},
      )
  
      metric.set_stream("test")
      self.assertDictEqual(
          metric.result(),
          {"test": {0: my_amca}, "train": {1: my_amca2}},
      )
  
      metric.finish_phase()
      metric.set_stream("train")
      self.assertDictEqual(
          metric.result(),
          {"test": {0: my_amca / 2}, "train": {1: my_amca2 / 2}},
      )
  
      metric.reset()
      self.assertDictEqual(
          metric.result(), {"test": {0: 0.0}, "train": {1: 0.0}}
      )
  
imports: import unittest
  import torch
  from avalanche.evaluation.metrics import TaskAwareAccuracy, TopkAccuracy, AverageMeanClassAccuracy, MultiStreamAMCA, ClassAccuracy, TaskAwareLoss, ConfusionMatrix, DiskUsage, MAC, CPUUsage, MaxGPU, MaxRAM, Mean, Sum, ElapsedTime, Forgetting, ForwardTransfer, CumulativeAccuracy, LabelsRepartition
  from tests.unit_tests_utils import FAST_TEST, is_github_action
label_desc: Use image node_id 12 for calling the GeneralMetricTests obj's underlying member method code with example usage: obj.test_multistream_amca_two_task_dynamic() without return types