<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_memory(self, session, space, offset, data, width, extended=False):
 """Write in an 8-bit, 16-bit, 32-bit, 64-bit value to the specified memory space and offset. Corresponds to viOut* functions of the VISA library. :param session: Unique logical identifier to a session. :param space: Specifies the address space. (Constants.*SPACE*) :param offset: Offset (in bytes) of the address or register from which to read. :param data: Data to write to bus. :param width: Number of bits to read. :param extended: Use 64 bits offset independent of the platform. :return: return value of the library call. :rtype: :class:`pyvisa.constants.StatusCode` """

        if width == 8:
            return self.out_8(session, space, offset, data, extended)
        elif width == 16:
            return self.out_16(session, space, offset, data, extended)
        elif width == 32:
            return self.out_32(session, space, offset, data, extended)
        elif width == 64:
            return self.out_64(session, space, offset, data, extended)

        raise ValueError('%s is not a valid size. Valid values are 8, 16, 32, or 64' % width)