code: def test_multiple_attach(usage):
      n_iters = 100
      errD_values = iter(np.random.rand(n_iters))
      errG_values = iter(np.random.rand(n_iters))
      D_x_values = iter(np.random.rand(n_iters))
      D_G_z1 = iter(np.random.rand(n_iters))
      D_G_z2 = iter(np.random.rand(n_iters))
  
      def update_fn(engine, batch):
          return {
              "errD": next(errD_values),
              "errG": next(errG_values),
              "D_x": next(D_x_values),
              "D_G_z1": next(D_G_z1),
              "D_G_z2": next(D_G_z2),
          }
  
      trainer = Engine(update_fn)
      alpha = 0.98
  
      # attach running average
      monitoring_metrics = ["errD", "errG", "D_x", "D_G_z1", "D_G_z2"]
      for metric in monitoring_metrics:
          foo = partial(lambda x, metric: x[metric], metric=metric)
          RunningAverage(alpha=alpha, output_transform=foo).attach(
              trainer, metric, usage
          )
  
      @trainer.on(usage.COMPLETED)
      def check_values(engine):
          values = []
          for metric in monitoring_metrics:
              values.append(engine.state.metrics[metric])
  
          values = set(values)
          assert len(values) == len(monitoring_metrics)
  
      data = list(range(n_iters))
      trainer.run(data)
  
imports: import warnings
  from functools import partial
  from itertools import accumulate
  import numpy
  import pytest
  import torch
  import ignite.distributed
  from ignite.engine import Engine, Events
  from ignite.metrics import Accuracy, RunningAverage
  from ignite.metrics.metric import RunningBatchWise, RunningEpochWise, SingleEpochRunningBatchWise
label_desc: Use image node_id 5 for calling a global function with example usage: test_multiple_attach(usage) and returns: dict