# Path: sockeye/utils.py
# def check_condition(condition: bool, error_message: str):
#     """
#     Check the condition and if it is not met, exit with the given error message
#     and error_code, similar to assertions.
# 
#     :param condition: Condition to check.
#     :param error_message: Error message to show to the user.
#     """
#     if not condition:
#         raise SockeyeError(error_message)


import logging
import sockeye.constants as C
from math import sqrt
from typing import Optional
from sockeye.utils import check_condition
def get_lr_scheduler(scheduler_type: str,
                     base_learning_rate: float,
                     learning_rate_t_scale: float,
                     learning_rate_reduce_factor: float,
                     learning_rate_reduce_num_not_improved: int,
                     learning_rate_warmup: int = 0,
                     max_updates: Optional[int] = None) -> Optional[LearningRateScheduler]:
    """
    Returns a learning rate scheduler.

    :param scheduler_type: Scheduler type.
    :param base_lr: Base learning rate.
    :param learning_rate_reduce_factor: Factor to reduce learning rate with.
    :param learning_rate_t_scale: Scaling factor for step number.
    :param learning_rate_reduce_num_not_improved: Number of checkpoints with no
           improvement after which learning rate is reduced.
    :param learning_rate_warmup: Number of initial updates during which the
                                 learning rate linearly increases.
    :param max_updates: Number of total training updates.

    :raises: ValueError if unknown scheduler_type

    :return: Learning rate scheduler.
    """
    if scheduler_type is None or scheduler_type == C.LR_SCHEDULER_NONE:
        return None
    if scheduler_type == C.LR_SCHEDULER_INV_SQRT_DECAY:
        return LearningRateSchedulerInvSqrtDecay(base_lr=base_learning_rate, warmup=learning_rate_warmup,
                                                 t_scale=learning_rate_t_scale)
    if scheduler_type == C.LR_SCHEDULER_LINEAR_DECAY:

# Path: sockeye/utils.py
# def check_condition(condition: bool, error_message: str):
#     """
#     Check the condition and if it is not met, exit with the given error message
#     and error_code, similar to assertions.
# 
#     :param condition: Condition to check.
#     :param error_message: Error message to show to the user.
#     """
#     if not condition:
#         raise SockeyeError(error_message)


# Path: sockeye/lr_scheduler.py
import logging
import sockeye.constants as C
from math import sqrt
from typing import Optional
from sockeye.utils import check_condition

def get_lr_scheduler(scheduler_type: str,
                     base_learning_rate: float,
                     learning_rate_t_scale: float,
                     learning_rate_reduce_factor: float,
                     learning_rate_reduce_num_not_improved: int,
                     learning_rate_warmup: int = 0,
                     max_updates: Optional[int] = None) -> Optional[LearningRateScheduler]:
    """
    Returns a learning rate scheduler.

    :param scheduler_type: Scheduler type.
    :param base_lr: Base learning rate.
    :param learning_rate_reduce_factor: Factor to reduce learning rate with.
    :param learning_rate_t_scale: Scaling factor for step number.
    :param learning_rate_reduce_num_not_improved: Number of checkpoints with no
           improvement after which learning rate is reduced.
    :param learning_rate_warmup: Number of initial updates during which the
                                 learning rate linearly increases.
    :param max_updates: Number of total training updates.

    :raises: ValueError if unknown scheduler_type

    :return: Learning rate scheduler.
    """
    if scheduler_type is None or scheduler_type == C.LR_SCHEDULER_NONE:
        return None
    if scheduler_type == C.LR_SCHEDULER_INV_SQRT_DECAY:
        return LearningRateSchedulerInvSqrtDecay(base_lr=base_learning_rate, warmup=learning_rate_warmup,
                                                 t_scale=learning_rate_t_scale)
    if scheduler_type == C.LR_SCHEDULER_LINEAR_DECAY:

        check_condition(max_updates is not None,