def _preprocess_data(self, X, Y=None, idxs=None, train=False):
C, F = X<EOL>if Y is not None:<EOL><INDENT>Y = np.array(Y).astype(np.float32)<EOL><DEDENT>if idxs is None:<EOL><INDENT>if Y is not None:<EOL><INDENT>return (<EOL>[<EOL>[<EOL>F.indices[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>F.data[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>]<EOL>for i in range(len(C))<EOL>],<EOL>Y,<EOL>)<EOL><DEDENT>else:<EOL><INDENT>return [<EOL>[<EOL>F.indices[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>F.data[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>]<EOL>for i in range(len(C))<EOL>]<EOL><DEDENT><DEDENT>if Y is not None:<EOL><INDENT>return (<EOL>[<EOL>[<EOL>F.indices[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>F.data[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>]<EOL>for i in idxs<EOL>],<EOL>Y[idxs],<EOL>)<EOL><DEDENT>else:<EOL><INDENT>return [<EOL>[<EOL>F.indices[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>F.data[F.indptr[i] : F.indptr[i + <NUM_LIT:1>]],<EOL>]<EOL>for i in idxs<EOL>]<EOL><DEDENT>
Preprocess the data:
1. Select subset of the input if idxs exists.

:param X: The input data of the model.
:type X: pair with candidates and corresponding features
:param Y: The labels of input data.
:type Y: list or numpy.array
:param idxs: The selected indices of input data.
:type idxs: list or numpy.array
:param train: Indicator of training set.
:type train: bool
:return: Preprocessed data.
:rtype: list of (features, feature_weights) pair