code: def test_create_lr_scheduler_with_warmup_cosine(
      warmup_end_value, T_0, T_mult
  ):
      lr = 0.2
      steps = 200
      warm_steps = 50
      warm_start = 0.023
  
      def get_optim():
          t1 = torch.zeros([1], requires_grad=True)
          return torch.optim.SGD([t1], lr=lr)
  
      def get_cos_shed():
          return CosineAnnealingWarmRestarts(
              optimizer, T_0=T_0, T_mult=T_mult
          )
  
      optimizer = get_optim()
      scheduler = get_cos_shed()
      cosine_lrs = []
      for i in range(steps):
          cosine_lrs.append(optimizer.param_groups[0]["lr"])
          scheduler.step()
  
      optimizer = get_optim()
      scheduler = create_lr_scheduler_with_warmup(
          get_cos_shed(),
          warmup_start_value=warm_start,
          warmup_end_value=warmup_end_value,
          warmup_duration=warm_steps,
      )
  
      warm_lrs = []
      real_warm_steps = (
          warm_steps
          if warmup_end_value is not None
          else (warm_steps - 1)
      )
      for epoch in range(real_warm_steps + steps):
          scheduler(None)
          warm_lrs.append(optimizer.param_groups[0]["lr"])
  
      if warmup_end_value is not None:
          np.testing.assert_allclose(
              np.linspace(warm_start, warmup_end_value, warm_steps),
              warm_lrs[:warm_steps],
          )
          assert warm_lrs[real_warm_steps:] == cosine_lrs
      else:
          np.testing.assert_allclose(
              np.linspace(warm_start, lr, warm_steps),
              warm_lrs[:warm_steps],
          )
          assert warm_lrs[real_warm_steps:] == cosine_lrs
  
imports: from unittest.mock import MagicMock, patch
  import numpy
  import pytest
  import torch
  from torch.optim.lr_scheduler import CosineAnnealingWarmRestarts, ExponentialLR, StepLR
  from ignite.engine import Engine, Events
  from ignite.handlers.param_scheduler import ConcatScheduler, CosineAnnealingScheduler, create_lr_scheduler_with_warmup, LinearCyclicalScheduler, LRScheduler, ParamGroupScheduler, ParamScheduler, PiecewiseLinear, ReduceLROnPlateauScheduler
  from tests.ignite.contrib.handlers import MockFP16DeepSpeedZeroOptimizer
label_desc: Use image node_id 27 for calling a global function with example usage: test_create_lr_scheduler_with_warmup_cosine(warmup_end_value, T_0, T_mult) and returns: torch, CosineAnnealingWarmRestarts