<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mean(self):
 """ Mean of all the values in the SArray, or mean image. Returns None on an empty SArray. Raises an exception if called on an SArray with non-numeric type or non-Image type. Returns ------- out : float | turicreate.Image Mean of all values in SArray, or image holding per-pixel mean across the input SArray. """

        with cython_context():
            if self.dtype == _Image:
                from  .. import extensions
                return extensions.generate_mean(self)
            else:
                return self.__proxy__.mean()