def create_scheduler(
        self, num_training_steps: int, optimizer: torch.optim.Optimizer = None
    ):
        """
        Setup the scheduler. The optimizer of the trainer must have been set up either before this method is called or
        passed as an argument.

        Args:
            num_training_steps (int): The number of training steps to do.
        """
        num_warmup_steps = self.args.get_warmup_steps(num_training_steps)
        lr_lambda = partial(
            _get_cosine_schedule_with_warmup_lr_lambda,
            num_warmup_steps=num_warmup_steps,
            num_training_steps=num_training_steps,
            num_cycles=0.5,
            final_lr_portion=self.args.final_lr_portion,
        )
        last_epoch = -1
        self.lr_scheduler = LambdaLR(optimizer, lr_lambda, last_epoch)
        self._created_lr_scheduler = True
        return self.lr_scheduler

        Setup the scheduler. The optimizer of the trainer must have been set up either before this method is called or
        passed as an argument.

        Args:
            num_training_steps (int): The number of training steps to do.
        
smoe/trainer/llama_lr_scheduling.py