<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):
 """Imaginary part of ``self``. Returns ------- imag : `NumpyTensor` Imaginary part this element as an element of a `NumpyTensorSpace` with real data type. Examples -------- Get the imaginary part: rn(3).element([ 1., 0., -3.]) Set the imaginary part: cn(3).element([ 1.+0.j, 2.+0.j, 3.+0.j]) Other array-like types and broadcasting: cn(3).element([ 1.+1.j, 2.+1.j, 3.+1.j]) cn(3).element([ 1.+2.j, 2.+3.j, 3.+4.j]) """

        if self.space.is_real:
            return self.space.zero()
        elif self.space.is_complex:
            real_space = self.space.astype(self.space.real_dtype)
            return real_space.element(self.data.imag)
        else:
            raise NotImplementedError('`imag` not defined for non-numeric '
                                      'dtype {}'.format(self.dtype))