<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ones(n, d=None):
 """ Creates a TT-vector of all ones"""

    c = _vector.vector()
    if d is None:
        c.n = _np.array(n, dtype=_np.int32)
        c.d = c.n.size
    else:
        c.n = _np.array([n] * d, dtype=_np.int32)
        c.d = d
    c.r = _np.ones((c.d + 1,), dtype=_np.int32)
    c.get_ps()
    c.core = _np.ones(c.ps[c.d] - 1)
    return c