<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(self, pos, size, **kwargs):
 """ Writes some data, loaded from the state, into the file. :param pos: The address to read the data to write from in memory :param size: The requested size of the write :return: The real length of the write """

        if type(pos) is str:
            raise TypeError("SimFileDescriptor.write takes an address and size. Did you mean write_data?")

        # Find a reasonable concrete size for the load since we don't want to concretize anything
        # This is copied from SimFile.read
        # TODO: refactor into a generic concretization strategy?
        if self.state.solver.symbolic(size):
            try:
                passed_max_size = self.state.solver.max(size, extra_constraints=(size < self.state.libc.max_packet_size,))
            except SimSolverError:
                passed_max_size = self.state.solver.min(size)
                l.warning("Symbolic write size is too large for threshold - concretizing to min (%d)", passed_max_size)
                self.state.solver.add(size == passed_max_size)
        else:
            passed_max_size = self.state.solver.eval(size)
            if passed_max_size > 2**13:
                l.warning("Program performing extremely large write")

        data = self.state.memory.load(pos, passed_max_size)
        return self.write_data(data, size, **kwargs)