<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fit_regression( polynomials, abscissas, evals, rule="LS", retall=False, order=0, alpha=-1, ):
 """ Fit a polynomial chaos expansion using linear regression. Args: polynomials (chaospy.poly.base.Poly):
 Polynomial expansion with ``polynomials.shape=(M,)`` and `polynomials.dim=D`. abscissas (numpy.ndarray):
 Collocation nodes with ``abscissas.shape == (D, K)``. evals (numpy.ndarray):
 Model evaluations with ``len(evals)=K``. retall (bool):
 If True return Fourier coefficients in addition to R. order (int):
 Tikhonov regularization order. alpha (float):
 Dampning parameter for the Tikhonov regularization. Calculated automatically if negative. Returns: (Poly, numpy.ndarray):
 Fitted polynomial with ``R.shape=evals.shape[1:]`` and ``R.dim=D``. The Fourier coefficients in the estimation. Examples: 0.5q0+0.5q1+1.0 """

    abscissas = numpy.asarray(abscissas)
    if len(abscissas.shape) == 1:
        abscissas = abscissas.reshape(1, *abscissas.shape)
    evals = numpy.array(evals)

    poly_evals = polynomials(*abscissas).T
    shape = evals.shape[1:]
    evals = evals.reshape(evals.shape[0], int(numpy.prod(evals.shape[1:])))

    if isinstance(rule, str):
        rule = rule.upper()

    if rule == "LS":
        uhat = linalg.lstsq(poly_evals, evals)[0]

    elif rule == "T":
        uhat = rlstsq(poly_evals, evals, order=order, alpha=alpha, cross=False)

    elif rule == "TC":
        uhat = rlstsq(poly_evals, evals, order=order, alpha=alpha, cross=True)

    else:

        from sklearn.linear_model.base import LinearModel
        assert isinstance(rule, LinearModel)
        uhat = rule.fit(poly_evals, evals).coef_.T

    evals = evals.reshape(evals.shape[0], *shape)

    approx_model = chaospy.poly.sum((polynomials*uhat.T), -1)
    approx_model = chaospy.poly.reshape(approx_model, shape)

    if retall == 1:
        return approx_model, uhat
    elif retall == 2:
        return approx_model, uhat, poly_evals
    return approx_model