# 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
# Copyright 2017--2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
# use this file except in compliance with the License. A copy of the License
# is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.


logger = logging.getLogger(__name__)


class LearningRateScheduler:
    """
    :param base_lr: Base learning rate.
    :param warmup: Number of initial updates during which the learning rate
                   linearly increases.
    :param t_scale: Scaling factor for step number.
    """
    def __init__(self, base_lr: float = 1.0, warmup: int = 0, t_scale: float = 1.0) -> None:
        self.base_lr = base_lr

# 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

# Copyright 2017--2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not
# use this file except in compliance with the License. A copy of the License
# is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.


logger = logging.getLogger(__name__)


class LearningRateScheduler:
    """
    :param base_lr: Base learning rate.
    :param warmup: Number of initial updates during which the learning rate
                   linearly increases.
    :param t_scale: Scaling factor for step number.
    """
    def __init__(self, base_lr: float = 1.0, warmup: int = 0, t_scale: float = 1.0) -> None:
        self.base_lr = base_lr

        check_condition(warmup >= 0, "warmup needs to be >= 0.")