def mean(self, axis=None, dtype=None, out=None, keepdims=False):
if axis == -<NUM_LIT:1>:<EOL><INDENT>axis = self.ndim<EOL><DEDENT>if axis is None:<EOL><INDENT>results = vectorize(mean)(self, axis, dtype, keepdims=False)<EOL>weights = self._sublengths<EOL>res = np.average(results, axis=None, weights=weights)<EOL>if keepdims:<EOL><INDENT>for i in range(self.ndim):<EOL><INDENT>res = expand_dims(res, res.ndim)<EOL><DEDENT><DEDENT><DEDENT>elif axis == self._distaxis:<EOL><INDENT>results = vectorize(mean)(self, axis, dtype, keepdims=True)<EOL>results = gather(results)<EOL>weights = (np.array(self._sublengths, dtype=np.float64) /<EOL>sum(self._sublengths))<EOL>ix = [slice(None)] * self.ndim<EOL>ix[axis] = <NUM_LIT:0><EOL>res = results[ix] * weights[<NUM_LIT:0>]<EOL>for i in range(<NUM_LIT:1>, self._n):<EOL><INDENT>ix[axis] = i<EOL>res = res + results[ix] * weights[i]<EOL><DEDENT>if keepdims:<EOL><INDENT>res = expand_dims(res, axis)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>res = vectorize(mean)(self, axis, dtype, keepdims=False)<EOL>if keepdims:<EOL><INDENT>res = expand_dims(res, axis)<EOL><DEDENT><DEDENT>if out is not None:<EOL><INDENT>out[:] = res<EOL><DEDENT>return res<EOL>
Compute the arithmetic mean along the specified axis.
        See np.mean() for details.