def vector_to_parameters(vector, dims):
    """Second helper function for gradient checking.
    The inverse of the previous function. Returning
    the parameters with given dimensions from a vector
    arguments:
    -vector: a numpy array of shape (n,1)
    -dims: a list with the dimensions of the parameters. Containing 1x2 arrays with the
           shape of each parameter, for example: dims = [[3,4], [3,1]] for two parameters, a weights 3x4 matrix and a
           bias parameter b of shape 4x1
           """
    n = len(dims)
    parameters = []
    end_dims = 0
    for ii in range(n):
        # if the parameter is b or db, with shape [n, 1]
        if dims[ii][1] == 1:
            parameter = vector[end_dims:end_dims+dims[ii][0]].reshape((dims[ii][0], dims[ii][1]))
            end_dims += dims[ii][0]
        else:   # if the parameter is W or dW
            parameter = vector[end_dims:end_dims+dims[ii][0]*dims[ii][1]].reshape((dims[ii][0], dims[ii][1]))
            end_dims += dims[ii][0]*dims[ii][1]

        parameters.append(parameter)
    return parameters