<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calc_extensions(self, extensions=None, Y_agg=None):
 """ Calculates the extension and their accounts For the calculation, y is aggregated across specified y categories The method calls .calc_system of each extension (or these given in the extensions parameter) Parameters extensions : list of strings, optional A list of key names of extensions which shall be calculated. Default: all dictionaries of IOSystem are assumed to be extensions Y_agg : pandas.DataFrame or np.array, optional The final demand aggregated (one category per country). Can be used to restrict the calculation of CBA of a specific category (e.g. households). Default: y is aggregated over all categories """


        ext_list = list(self.get_extensions(data=False))
        extensions = extensions or ext_list
        if type(extensions) == str:
            extensions = [extensions]

        for ext_name in extensions:
            self.meta._add_modify(
                'Calculating accounts for extension {}'.format(ext_name))
            ext = getattr(self, ext_name)
            ext.calc_system(x=self.x,
                            Y=self.Y,
                            L=self.L,
                            Y_agg=Y_agg,
                            population=self.population
                            )
        return self