code: def test_override_required_output_keys():
      # https://github.com/pytorch/ignite/issues/1415
      from ignite.engine import create_supervised_evaluator
  
      counter = [0]
  
      class DummyLoss2(Loss):
          def __init__(self, *args, **kwargs):
              super().__init__(*args, **kwargs)
  
          def update(self, output):
              y_pred, y, criterion_kwargs = output
              assert y_pred.shape == (4, 3)
              assert y.shape == (4,)
              assert criterion_kwargs == c_kwargs
              assert y.equal(data[counter[0]][1])
              counter[0] += 1
  
          def reset(self):
              pass
  
          def compute(self):
              pass
  
      model = nn.Linear(10, 3)
  
      metrics = {
          "Precision": Precision(),
          "DummyLoss2": DummyLoss2(nll_loss),
      }
  
      # global criterion kwargs
      c_kwargs = {"reduction": "sum"}
  
      evaluator = create_supervised_evaluator(
          model,
          metrics=metrics,
          output_transform=lambda x, y, y_pred: {
              "x": x,
              "y": y,
              "y_pred": y_pred,
              "criterion_kwargs": c_kwargs,
          },
      )
  
      data = [
          (torch.rand(4, 10), torch.randint(0, 3, size=(4,))),
          (torch.rand(4, 10), torch.randint(0, 3, size=(4,))),
          (torch.rand(4, 10), torch.randint(0, 3, size=(4,))),
      ]
      evaluator.run(data)
  
imports: import os
  from unittest.mock import MagicMock
  import pytest
  import torch
  from numpy.testing import assert_almost_equal
  from torch import nn
  from torch.nn.functional import nll_loss
  import ignite.distributed
  from ignite.engine import State
  from ignite.exceptions import NotComputableError
  from ignite.metrics import Loss, Precision
label_desc: Use image node_id 23 for calling a global function with example usage: test_override_required_output_keys() without return types