<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def within(self, x, ctrs, kdtree=None):
 """Check which balls `x` falls within. Uses a K-D Tree to perform the search if provided."""


        if kdtree is None:
            # If no K-D Tree is provided, execute a brute-force
            # search over all balls.
            idxs = np.where(lalg.norm(ctrs - x, axis=1) <= self.radius)[0]
        else:
            # If a K-D Tree is provided, find all points within `self.radius`.
            idxs = kdtree.query_ball_point(x, self.radius, p=2.0, eps=0)

        return idxs