<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def points_to_spline_entity(points, smooth=None, count=None):
 """ Create a spline entity from a curve in space Parameters points: (n, dimension) float, points in space smooth: float, smoothing amount count: int, number of samples in result Returns --------- entity: entities.BSpline object with points indexed at zero control: (m, dimension) float, new vertices for entity """


    from scipy.interpolate import splprep
    if count is None:
        count = len(points)
    if smooth is None:
        smooth = 0.002

    points = np.asanyarray(points, dtype=np.float64)
    closed = np.linalg.norm(points[0] - points[-1]) < tol.merge

    knots, control, degree = splprep(points.T, s=smooth)[0]
    control = np.transpose(control)
    index = np.arange(len(control))

    if closed:
        control[0] = control[[0, -1]].mean(axis=0)
        control = control[:-1]
        index[-1] = index[0]

    entity = entities.BSpline(points=index,
                              knots=knots,
                              closed=closed)

    return entity, control