<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def top_features(self, featureset_name, topn=20, by='counts', perslice=False, slice_kwargs={}):
 """ Retrieves the top ``topn`` most numerous features in the corpus. Parameters featureset_name : str Name of a :class:`.FeatureSet` in the :class:`.Corpus`\. topn : int (default: ``20``) Number of features to return. by : str (default: ``'counts'``) If ``'counts'``, uses the sum of feature count values to rank features. If ``'documentCounts'``, uses the number of papers in which features occur. perslice : bool (default: False) If True, retrieves the top ``topn`` features in each slice. slice_kwargs : kwargs If ``perslice=True``, these keyword arguments are passed to :meth:`.Corpus.slice`\. """


        if perslice:
            return [(k, subcorpus.features[featureset_name].top(topn, by=by))
                    for k, subcorpus in self.slice(**slice_kwargs)]
        return self.features[featureset_name].top(topn, by=by)