<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def inspect_last(self, stream, only_allocated=False):
 """Return the last value pushed into a stream. This function works even if the stream is virtual and no virtual walker has been created for it. It is primarily useful to aid in debugging sensor graphs. Args: stream (DataStream):
 The stream to inspect. only_allocated (bool):
 Optional parameter to only allow inspection of allocated virtual streams. This is useful for mimicking the behavior of an embedded device that does not have a _last_values array. Returns: IOTileReading: The data in the stream Raises: StreamEmptyError: if there has never been data written to the stream. UnresolvedIdentifierError: if only_allocated is True and there has not been a virtual stream walker allocated to listen to this stream. """


        if only_allocated:
            found = False
            for walker in self._virtual_walkers:
                if walker.matches(stream):
                    found = True
                    break

            if not found:
                raise UnresolvedIdentifierError("inspect_last could not find an allocated virtual streamer for the desired stream", stream=stream)

        if stream in self._last_values:
            return self._last_values[stream]

        raise StreamEmptyError(u"inspect_last called on stream that has never been written to", stream=stream)