def vec_centered(x, length):
    """Returns the central part of a vector of a specified length

    Args:
        x (jax.numpy.ndarray): A line vector.
        length (int): Length of the central part of x which will be retained.

    Returns:
        jax.numpy.ndarray: central part of x of the specified length. 
    """
    cur_len = len(x)
    length = min(cur_len, length) 
    start = (len(x) - length) // 2
    end = start + length
    return x[start:end]