code: def collect(self, start=None, stop=None, count=None):
      def bisect(target, left, right):
          if left == right:
              return left
  
          mid = (left + right) // 2
          value = max(
              startstop["stop"]
              for startstop in self.buffer[mid]["startstops"]
          )
  
          if value < target:
              return bisect(target, mid + 1, right)
          else:
              return bisect(target, left, mid)
  
      if isinstance(start, str):
          start = time() - parse_timedelta(start)
      if start is not None:
          start = bisect(start, 0, len(self.buffer))
  
      if isinstance(stop, str):
          stop = time() - parse_timedelta(stop)
      if stop is not None:
          stop = bisect(stop, 0, len(self.buffer))
  
      if count is not None:
          if start is None and stop is None:
              stop = len(self.buffer)
              start = stop - count
          elif start is None and stop is not None:
              start = stop - count
          elif start is not None and stop is None:
              stop = start + count
  
      if stop is None:
          stop = len(self.buffer)
      if start is None:
          start = 0
  
      start = max(0, start)
      stop = min(stop, len(self.buffer))
  
      return [self.buffer[i] for i in range(start, stop)]
  
file_path: distributed/distributed/diagnostics/task_stream.py
imports: from __future__ import annotations
  import logging
  from collections import deque
  import dask
  from dask.utils import format_time, key_split, parse_timedelta
  from distributed.diagnostics.plugin import SchedulerPlugin
  from distributed.diagnostics.progress_stream import color_of
  from distributed.metrics import time
label_desc: Use image node_id 3 for calling the TaskStreamPlugin obj's underlying member method code with example usage: obj.collect(start, stop, count) and returns: unknown, left, bisect, bisect