code: def test_integration_as_context_manager(dirname):
      n_epochs = 5
      data = list(range(50))
  
      losses = torch.rand(n_epochs * len(data))
      losses_iter = iter(losses)
  
      def update_fn(engine, batch):
          return next(losses_iter)
  
      true_values = []
  
      with MLflowLogger(str(dirname / "mlruns")) as mlflow_logger:
          trainer = Engine(update_fn)
  
          def dummy_handler(engine, logger, event_name):
              global_step = engine.state.get_event_attrib_value(
                  event_name
              )
              v = global_step * 0.1
              true_values.append(v)
              logger.log_metrics({"test_value": v}, step=global_step)
  
          mlflow_logger.attach(
              trainer,
              log_handler=dummy_handler,
              event_name=Events.EPOCH_COMPLETED,
          )
  
          import mlflow
  
          active_run = mlflow.active_run()
  
          trainer.run(data, max_epochs=n_epochs)
  
      from mlflow.tracking import MlflowClient
  
      client = MlflowClient(tracking_uri=str(dirname / "mlruns"))
      stored_values = client.get_metric_history(
          active_run.info.run_id, "test_value"
      )
  
      for t, s in zip(true_values, stored_values):
          assert pytest.approx(t) == s.value
  
file_path: ignite/tests/ignite/contrib/handlers/test_mlflow_logger.py
imports: import sys
  from unittest.mock import call, MagicMock
  import pytest
  import torch
  from ignite.contrib.handlers.mlflow_logger import global_step_from_engine, MLflowLogger, OptimizerParamsHandler, OutputHandler
  from ignite.engine import Engine, Events, State
label_desc: Use image node_id 12 for calling a global function with example usage: test_integration_as_context_manager(dirname) and returns: next