code: def test_metrics_lambda():
      m0 = ListGatherMetric(0)
      m1 = ListGatherMetric(1)
      m2 = ListGatherMetric(2)
  
      def process_function(engine, data):
          return data
  
      engine = Engine(process_function)
  
      def plus(this, other):
          return this + other
  
      m0_plus_m1 = MetricsLambda(plus, m0, other=m1)
      m2_plus_2 = MetricsLambda(plus, m2, 2)
      m0_plus_m1.attach(engine, "m0_plus_m1")
      m2_plus_2.attach(engine, "m2_plus_2")
  
      engine.run([[1, 10, 100]])
      assert engine.state.metrics["m0_plus_m1"] == 11
      assert engine.state.metrics["m2_plus_2"] == 102
      engine.run([[2, 20, 200]])
      assert engine.state.metrics["m0_plus_m1"] == 22
      assert engine.state.metrics["m2_plus_2"] == 202
  
      # metrics are partially attached
      assert not m0.is_attached(engine)
      assert not m1.is_attached(engine)
      assert not m2.is_attached(engine)
  
      # a dependency is detached
      m0.detach(engine)
      # so the lambda metric is too
      assert not m0_plus_m1.is_attached(engine)
      # the lambda is attached again
      m0_plus_m1.attach(engine, "m0_plus_m1")
      assert m0_plus_m1.is_attached(engine)
      # metrics are always partially attached
      assert not m0.is_attached(engine)
      m0_plus_m1.detach(engine)
      assert not m0_plus_m1.is_attached(engine)
      # detached (and no longer partially attached)
      assert not m0.is_attached(engine)
  
imports: import os
  import numpy
  import pytest
  import torch
  from pytest import approx
  from sklearn.metrics import f1_score, precision_score, recall_score
  import ignite.distributed
  from ignite.engine import Engine
  from ignite.metrics import Accuracy, Metric, MetricsLambda, Precision, Recall
label_desc: Use image node_id 1 for calling a global function with example usage: test_metrics_lambda() and returns: data, unknown