<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def average_series(self, *args, **kwargs) -> InfoArray: """Average the actual time series of the |Variable| object for all time points. Method |IOSequence.average_series| works similarly as method |Variable.average_values| of class |Variable|, from which we borrow some examples. However, firstly, we have to prepare a |Timegrids| object to define the |IOSequence.series| length: As shown for method |Variable.average_values|, for 0-dimensional |IOSequence| objects the result of |IOSequence.average_series| equals |IOSequence.series| itself: InfoArray([ 190., 200., 210.]) For |IOSequence| objects with an increased dimensionality, a weighting parameter is required, again: InfoArray([ 390., 400., 410.]) The documentation on method |Variable.average_values| provides many examples on how to use different masks in different ways. Here we restrict ourselves to the first example, where a new mask enforces that |IOSequence.average_series| takes only the first two columns of the `series` into account: InfoArray([ 290., 300., 310.]) """

        try:
            if not self.NDIM:
                array = self.series
            else:
                mask = self.get_submask(*args, **kwargs)
                if numpy.any(mask):
                    weights = self.refweights[mask]
                    weights /= numpy.sum(weights)
                    series = self.series[:, mask]
                    axes = tuple(range(1, self.NDIM+1))
                    array = numpy.sum(weights*series, axis=axes)
                else:
                    return numpy.nan
            return InfoArray(array, info={'type': 'mean'})
        except BaseException:
            objecttools.augment_excmessage(
                'While trying to calculate the mean value of '
                'the internal time series of sequence %s'
                % objecttools.devicephrase(self))