code: async def takelast(source, n):
      
      queue = collections.deque(maxlen=n if n > 0 else 0)
      async with streamcontext(source) as streamer:
          async for item in streamer:
              queue.append(item)
          for item in queue:
              yield item
docs: Forward the last ``n`` elements from an asynchronous sequence.
  
      If ``n`` is negative, it simply terminates after iterating the source.
  
      Note: it is required to reach the end of the source before the first
      element is generated.