<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def in_memory(self, op_in_mem):
 r""" If set to True, the output will be stored in memory. """

        old_state = self.in_memory
        if not old_state and op_in_mem:
            self._map_to_memory()
        elif not op_in_mem and old_state:
            self._clear_in_memory()