<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, newimag):
 """Set the imaginary part of this element to ``newimag``. This method is invoked by ``x.imag = other``. Parameters newimag : array-like or scalar Values to be assigned to the imaginary part of this element. Raises ------ ValueError If the space is real, i.e., no imagninary part can be set. """

        if self.space.is_real:
            raise ValueError('cannot set imaginary part in real spaces')
        self.tensor.imag = newimag