def METHOD_NAME(parameters, step_each_epoch, params):
    import paddle
    from paddle.regularizer import L2Decay
    learning_rate = params.learning_rate
    num_epochs = params.num_epochs
    if params.lr_policy == 'Piecewise':
        lr_decay_epochs = params.lr_decay_epochs
        gamma = 0.1
        boundaries = [step_each_epoch * e for e in lr_decay_epochs]
        values = [
            learning_rate * (gamma**i)
            for i in range(len(lr_decay_epochs) + 1)
        ]
        decayed_lr = paddle.optimizer.lr.PiecewiseDecay(
            boundaries=boundaries, values=values)
    elif params.lr_policy == 'Polynomial':
        decay_step = num_epochs * step_each_epoch
        decayed_lr = paddle.optimizer.lr.PolynomialDecay(
            learning_rate=learning_rate,
            decay_steps=decay_step,
            end_lr=0.0,
            power=.9)
    elif params.lr_policy == 'Cosine':
        decayed_lr = paddle.optimizer.lr.CosineAnnealingDecay(
            learning_rate=.001, T_max=step_each_epoch * num_epochs)
    else:
        raise Exception(
            'lr_policy only support Polynomial or Piecewise, but you set {}'.
            format(params.lr_policy))
    if params.optimizer.lower() == 'sgd':
        momentum = 0.9
        regularize_coef = 1e-4
        optimizer = paddle.optimizer.Momentum(
            learning_rate=decayed_lr,
            momentum=momentum,
            weight_decay=L2Decay(regularize_coef),
            parameters=parameters)
    elif params.optimizer.lower() == 'adam':
        momentum = 0.9
        momentum2 = 0.999
        regularize_coef = 1e-4
        optimizer = paddle.optimizer.Adam(
            learning_rate=decayed_lr,
            beta1=momentum,
            beta2=momentum2,
            weight_decay=L2Decay(regularize_coef),
            parameters=parameters)
    return optimizer