code: def get_cosine_with_hard_restarts_schedule_with_warmup(
      optimizer: Optimizer,
      num_warmup_steps: int,
      num_training_steps: int,
      num_cycles: int = 1,
      last_epoch: int = -1,
  ):
      """
      Create a schedule with a learning rate that decreases following the values of the cosine function between the
      initial lr set in the optimizer to 0, with several hard restarts, after a warmup period during which it increases
      linearly between 0 and the initial lr set in the optimizer.
  
      Args:
          optimizer ([`~torch.optim.Optimizer`]):
              The optimizer for which to schedule the learning rate.
          num_warmup_steps (`int`):
              The number of steps for the warmup phase.
          num_training_steps (`int`):
              The total number of training steps.
          num_cycles (`int`, *optional*, defaults to 1):
              The number of hard restarts to use.
          last_epoch (`int`, *optional*, defaults to -1):
              The index of the last epoch when resuming training.
  
      Return:
          `torch.optim.lr_scheduler.LambdaLR` with the appropriate schedule.
      """
  
      def lr_lambda(current_step):
          if current_step < num_warmup_steps:
              return float(current_step) / float(
                  max(1, num_warmup_steps)
              )
          progress = float(current_step - num_warmup_steps) / float(
              max(1, num_training_steps - num_warmup_steps)
          )
          if progress >= 1.0:
              return 0.0
          return max(
              0.0,
              0.5
              * (
                  1.0
                  + math.cos(
                      math.pi * ((float(num_cycles) * progress) % 1.0)
                  )
              ),
          )
  
      return LambdaLR(optimizer, lr_lambda, last_epoch)
  
imports: import math
  import warnings
  from typing import Callable, Iterable, Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.optim import Optimizer
  from torch.optim.lr_scheduler import LambdaLR
  from .trainer_utils import SchedulerType
  from .utils import logging
  from .utils.versions import require_version
label_desc: Use image node_id 5 for calling a global function with example usage: get_cosine_with_hard_restarts_schedule_with_warmup(optimizer, num_warmup_steps, num_training_steps, num_cycles, last_epoch) and returns: LambdaLR, max, unknown, int