def scalar_mul(eta, x):
    """Scalar multiplication. Return a list with the same dimensions as `x`
    where each element in `x` is multiplied by `eta`.

    Args:
        eta (float) Scalar to apply to `x`.
        x (list): Vector to scale. 1 or 2 dimensional.

    Returns:
        list: A scaled list. Same dimensions as `x`.

    """
    if isinstance(x[0], list):  # 2 dimensional
        return [[eta * x_ij for x_ij in x_i] for x_i in x]
    else:  # 1 dimensional
        return [eta * x_i for x_i in x]