<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_points(self, remove, mode='any', keep_scalars=True, inplace=False):
 """ Rebuild a mesh by removing points. Only valid for all-triangle meshes. Parameters remove : np.ndarray If remove is a bool array, points that are True will be removed. Otherwise, it is treated as a list of indices. mode : str, optional When 'all', only faces containing all points flagged for removal will be removed. Default 'all' keep_scalars : bool, optional When True, point and cell scalars will be passed on to the new mesh. inplace : bool, optional Updates mesh in-place while returning nothing. Returns ------- mesh : vtki.PolyData Mesh without the points flagged for removal. Not returned when inplace=False. ridx : np.ndarray Indices of new points relative to the original mesh. Not returned when inplace=False. """

        if isinstance(remove, list):
            remove = np.asarray(remove)

        if remove.dtype == np.bool:
            if remove.size != self.n_points:
                raise AssertionError('Mask different size than n_points')
            remove_mask = remove
        else:
            remove_mask = np.zeros(self.n_points, np.bool)
            remove_mask[remove] = True

        try:
            f = self.faces.reshape(-1, 4)[:, 1:]
        except:
            raise Exception('Mesh must consist of only triangles')

        vmask = remove_mask.take(f)
        if mode == 'all':
            fmask = ~(vmask).all(1)
        else:
            fmask = ~(vmask).any(1)

        # Regenerate face and point arrays
        uni = np.unique(f.compress(fmask, 0), return_inverse=True)
        new_points = self.points.take(uni[0], 0)

        nfaces = fmask.sum()
        faces = np.empty((nfaces, 4), dtype=vtki.ID_TYPE)
        faces[:, 0] = 3
        faces[:, 1:] = np.reshape(uni[1], (nfaces, 3))

        newmesh = PolyData(new_points, faces, deep=True)
        ridx = uni[0]

        # Add scalars back to mesh if requested
        if keep_scalars:
            for key in self.point_arrays:
                newmesh.point_arrays[key] = self.point_arrays[key][ridx]

            for key in self.cell_arrays:
                try:
                    newmesh.cell_arrays[key] = self.cell_arrays[key][fmask]
                except:
                    log.warning('Unable to pass cell key %s onto reduced mesh' %
                                key)

        # Return vtk surface and reverse indexing array
        if inplace:
            self.overwrite(newmesh)
        else:
            return newmesh, ridx