code: def test_integration_as_context_manager():
      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)
  
      with NeptuneLogger(mode="offline") as npt_logger:
          trainer = Engine(update_fn)
  
          def dummy_handler(engine, logger, event_name):
              global_step = engine.state.get_event_attrib_value(
                  event_name
              )
              logger["test_value"].append(global_step, step=global_step)
  
          npt_logger.attach(
              trainer,
              log_handler=dummy_handler,
              event_name=Events.EPOCH_COMPLETED,
          )
  
          trainer.run(data, max_epochs=n_epochs)
  
imports: import math
  import warnings
  from unittest.mock import MagicMock
  import pytest
  import torch
  from ignite.contrib.handlers.neptune_logger import global_step_from_engine, GradsScalarHandler, NeptuneLogger, NeptuneSaver, OptimizerParamsHandler, OutputHandler, WeightsScalarHandler
  from ignite.engine import Engine, Events, State
label_desc: Use image node_id 19 for calling a global function with example usage: test_integration_as_context_manager() and returns: next