<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def AIC(data, model, params=None, corrected=True):
 """ Akaike Information Criteria given data and a model Parameters {0} {1} params : int Number of parameters in the model. If None, calculated from model object. corrected : bool If True, calculates the small-sample size correct AICC. Default True. Returns ------- float AIC(C) value Notes ----- AICC should be used when the number of observations is < 40. Examples -------- 765.51518598676421 777.05165086534805 765.51518598676421 765.39147464655798 References .. [#] Burnham, K and Anderson, D. (2002) Model Selection and Multimodel Inference: A Practical and Information-Theoretic Approach (p. 66). New York City, USA: Springer. """

    n = len(data)  # Number of observations
    L = nll(data, model)

    if not params:
        k = len(model.kwds) + len(model.args)
    else:
        k = params

    if corrected:
        aic_value = 2 * k + 2 * L + (2 * k * (k + 1)) / (n - k - 1)
    else:
        aic_value = 2 * k + 2 * L

    return aic_value