code: def configure_linear_scheduler_with_warmup(
      optimizer, num_warmup_steps, num_training_steps, last_epoch=-1
  ):
      """
      Return a scheduler with a learning rate that decreases linearly from the initial lr set in the optimizer to 0, after
      a warmup period during which it increases linearly from 0 to the initial lr set in the optimizer.
  
      Args:
          optimizer (`Optimizer`):
              The optimizer to be scheduled.
          num_warmup_steps (`int`):
              Warmup steps.
          num_training_steps (`int`):
              Training steps.
          last_epoch (`int`):
              The last epoch when training is resumed.
  
      Return (`LambdaLR`):
          A linear scheduler with warmup.
  
      Example:
          >>> from towhee.trainer.scheduler import configure_linear_scheduler_with_warmup
          >>> from towhee.trainer.optimization.adamw import AdamW
          >>> from torch import nn
          >>> def unwrap_scheduler(scheduler, num_steps=10):
          >>>     lr_sch = []
          >>>     for _ in range(num_steps):
          >>>         lr_sch.append(scheduler.get_lr()[0])
          >>>         scheduler.step()
          >>>     return lr_sch
          >>> mdl = nn.Linear(50, 50)
          >>> optimizer = AdamW(mdl.parameters(), lr=10.0)
          >>> num_steps = 10
          >>> num_warmup_steps = 4
          >>> num_training_steps = 10
          >>> scheduler = configure_constant_scheduler_with_warmup(optimizer, num_warmup_steps, num_training_steps)
          >>> lr_sch_1 = unwrap_scheduler(scheduler, num_steps)
          [0.0, 2.5, 5.0, 7.5, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0]
      """
  
      def lr_lambda(current_step: int):
          if current_step < num_warmup_steps:
              return float(current_step) / float(
                  max(1, num_warmup_steps)
              )
          return max(
              0.0,
              float(num_training_steps - current_step)
              / float(max(1, num_training_steps - num_warmup_steps)),
          )
  
      return LambdaLR(optimizer, lr_lambda, last_epoch)
  
file_path: towhee/towhee/trainer/scheduler.py
imports: import math
  from torch.optim.lr_scheduler import LambdaLR
  from torch.optim.optimizer import Optimizer
label_desc: Use image node_id 4 for calling a global function with example usage: configure_linear_scheduler_with_warmup(optimizer, num_warmup_steps, num_training_steps, last_epoch) and returns: LambdaLR, max, unknown