<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def feature_distribution(self, featureset_name, feature, mode='counts', **slice_kwargs):
 """ Calculates the distribution of a feature across slices of the corpus. Examples -------- .. code-block:: python [2, 15, 25, 1] Parameters featureset_name : str Name of a :class:`.FeatureSet` in the :class:`.Corpus`\. feature : str Name of the specific feature of interest. E.g. if ``featureset_name='citations'``, then ``feature`` could be something like ``'DOLE RJ 1965 CELL'``. mode : str (default: ``'counts'``) If set to ``'counts'``, values will be the sum of all count values for the feature in each slice. If set to ``'documentCounts'``, values will be the number of papers in which the feature occurs in each slice. slice_kwargs : kwargs Keyword arguments to be passed to :meth:`.Corpus.slice`\. Returns ------- list """


        values = []
        keys = []
        fset = self.features[featureset_name]

        for key, papers in self.slice(subcorpus=False, **slice_kwargs):
            allfeatures = [v for v
                           in chain(*[fset.features[self._generate_index(p)]
                                      for p in papers
                                      if self._generate_index(p)
                                      in fset.features])]

            if len(allfeatures) < 1:
                keys.append(key)
                values.append(0.)
                continue

            count = 0.
            for elem, v in allfeatures:
                if elem != feature:
                    continue
                if mode == 'counts':
                    count += v
                else:
                    count += 1.
            values.append(count)
            keys.append(key)
        return keys, values