<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def imag(self):
 """Element-wise imaginary part Raises: NoConjugateMatrix: if entries have no `conjugate` method and no other way to determine the imaginary part Note: A mathematically equivalent way to obtain an imaginary matrix from a complex matrix ``M`` is:: (M.conjugate() - M) / (I * 2) with same same caveats as :attr:`real`. """


        def im(val):
            if hasattr(val, 'imag'):
                return val.imag
            elif hasattr(val, 'as_real_imag'):
                return val.as_real_imag()[1]
            elif hasattr(val, 'conjugate'):
                return (val.conjugate() - val) / (2 * I)
            else:
                raise NoConjugateMatrix(
                    "Matrix entry %s contains has no defined "
                    "conjugate" % str(val))

        # Note: Do NOT use self.matrix.real! This will give wrong results, as
        # numpy thinks of objects (Operators) as real, even if they have no
        # defined real part
        return self.element_wise(im)