def apply(self, doc, split, train, **kwargs):
logger.debug(f"<STR_LIT>")<EOL>cands_list = get_cands_list_from_split(<EOL>self.session, self.candidate_classes, doc, split<EOL>)<EOL>feature_map = dict()<EOL>all_cands = itertools.chain.from_iterable(cands_list)<EOL>records = list(<EOL>get_mapping(self.session, Feature, all_cands, get_all_feats, feature_map)<EOL>)<EOL>batch_upsert_records(self.session, Feature, records)<EOL>if train:<EOL><INDENT>upsert_keys(self.session, FeatureKey, feature_map)<EOL><DEDENT>return<EOL>yield<EOL>
Extract candidates from the given Context.

        :param doc: A document to process.
        :param split: Which split to use.
        :param train: Whether or not to insert new FeatureKeys.