code: def test_ema_warmup_func(get_dummy_model):
      """Test the built-in linear warmup function for the EMA momentum"""
      momentum = 0.5
      momentum_warmup_1 = 0.0
      momentum_warmup_2 = 1.0
      warmup_iters = 5
  
      def check_ema_momentum(
          engine: Engine, momentum_warmup, final_momentum, warmup_iters
      ):
          if engine.state.iteration == 1:
              assert engine.state.ema_momentum == momentum_warmup
          elif engine.state.iteration >= 1 + warmup_iters:
              assert engine.state.ema_momentum == final_momentum
          else:
              min_momentum = min(momentum, momentum_warmup)
              max_momentum = max(momentum, momentum_warmup)
              assert (
                  min_momentum
                  <= engine.state.ema_momentum
                  <= max_momentum
              )
  
      # momentum_warmup < momentum
      model_1 = get_dummy_model()
      engine_1 = Engine(_get_dummy_step_fn(model_1))
      ema_handler_1 = EMAHandler(
          model_1, momentum, momentum_warmup_1, warmup_iters
      )
      ema_handler_1.attach(engine_1)
      engine_1.add_event_handler(
          Events.ITERATION_COMPLETED,
          check_ema_momentum,
          momentum_warmup_1,
          momentum,
          warmup_iters,
      )
      engine_1.run(range(10))
  
      # momentum_warmup > momentum
      model_2 = get_dummy_model()
      engine_2 = Engine(_get_dummy_step_fn(model_2))
      ema_handler_2 = EMAHandler(
          model_2, momentum, momentum_warmup_2, warmup_iters
      )
      ema_handler_2.attach(engine_2)
      engine_2.add_event_handler(
          Events.ITERATION_COMPLETED,
          check_ema_momentum,
          momentum_warmup_2,
          momentum,
          warmup_iters,
      )
      engine_2.run(range(10))
  
imports: import os
  from typing import Any, Callable, Union
  import pytest
  import torch
  import torch.nn
  from torch.nn.parallel import DataParallel, DistributedDataParallel
  import ignite.distributed
  from ignite.engine import Engine, Events
  from ignite.handlers import EMAHandler
label_desc: Use image node_id 7 for calling a global function with example usage: test_ema_warmup_func(get_dummy_model) without return types