code: def test_output_handler_both():
      wrapper = OutputHandler(
          "tag",
          metric_names=["a", "b"],
          output_transform=lambda x: {"loss": x},
      )
      mock_logger = MagicMock(spec=TensorboardLogger)
      mock_logger.writer = MagicMock()
  
      mock_engine = MagicMock()
      mock_engine.state = State(metrics={"a": 12.23, "b": 23.45})
      mock_engine.state.epoch = 5
      mock_engine.state.output = 12345
  
      wrapper(mock_engine, mock_logger, Events.EPOCH_STARTED)
  
      assert mock_logger.writer.add_scalar.call_count == 3
      mock_logger.writer.add_scalar.assert_has_calls(
          [
              call("tag/a", 12.23, 5),
              call("tag/b", 23.45, 5),
              call("tag/loss", 12345, 5),
          ],
          any_order=True,
      )
  
imports: import math
  import os
  from unittest.mock import ANY, call, MagicMock, patch
  import pytest
  import torch
  from ignite.contrib.handlers.tensorboard_logger import global_step_from_engine, GradsHistHandler, GradsScalarHandler, OptimizerParamsHandler, OutputHandler, TensorboardLogger, WeightsHistHandler, WeightsScalarHandler
  from ignite.engine import Engine, Events, State
label_desc: Use image node_id 7 for calling a global function with example usage: test_output_handler_both() without return types