<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_values(self, *args, **kwargs) -> float: """Average the actual values of the |Variable| object. For 0-dimensional |Variable| objects, the result of method |Variable.average_values| equals |Variable.value|. The following example shows this for the sloppily defined class `SoilMoisture`: 200.0 When the dimensionality of this class is increased to one, applying method |Variable.average_values| results in the following error: Traceback (most recent call last):
 AttributeError: While trying to calculate the mean value \ of variable `soilmoisture`, the following error occurred: Variable \ `soilmoisture` does not define any weighting coefficients. So model developers have to define another (in this case 1-dimensional) |Variable| subclass (usually a |Parameter| subclass), and make the relevant object available via property |Variable.refweights|: 400.0 In the examples above, all single entries of `values` are relevant, which is the default case. However, subclasses of |Variable| can define an alternative mask, allowing to make some entries irrelevant. Assume for example, that our `SoilMoisture` object contains three single values, each one associated with a specific hydrological response unit (hru). To indicate that soil moisture is undefined for the third unit, (maybe because it is a water area), we set the third entry of the verification mask to |False|: 300.0 Alternatively, method |Variable.average_values| accepts additional masking information as positional or keyword arguments. Therefore, the corresponding model must implement some alternative masks, which are provided by property |Variable.availablemasks|. We mock this property with a new |Masks| object, handling one mask for flat soils (only the first hru), one mask for deep soils (only the second hru), and one mask for water areas (only the third hru):
 One can pass either the mask classes themselves or their names: 200.0 400.0 Both variants can be combined: 300.0 The following error happens if the general mask of the variable does not contain the given masks: Traceback (most recent call last):
 ValueError: While trying to calculate the mean value of variable \ `soilmoisture`, the following error occurred: Based on the arguments \ `('flatsoil', 'water')` and `{}` the mask `CustomMask([ True, False, True])` \ has been determined, which is not a submask of `Soil([ True, True, False])`. Applying masks with custom options is also supported. One can change the behaviour of the following mask via the argument `complete`: Again, one can apply the mask class directly (but note that one has to pass the relevant variable as the first argument.):
 Traceback (most recent call last):
 Alternatively, one can pass the mask name as a keyword and pack the mask's options into a |dict| object: nan You can combine all variants explained above: 300.0 """

        try:
            if not self.NDIM:
                return self.value
            mask = self.get_submask(*args, **kwargs)
            if numpy.any(mask):
                weights = self.refweights[mask]
                return numpy.sum(weights*self[mask])/numpy.sum(weights)
            return numpy.nan
        except BaseException:
            objecttools.augment_excmessage(
                f'While trying to calculate the mean value of variable '
                f'{objecttools.devicephrase(self)}')