class_docstr: Analyse historical data to optimize CorkDispatcher.
class_docstr_tok: ["Analyse","historical","data","to","optimize","CorkDispatcher","."]
docstr: assume the outbound duration follows duration = o_a * n + o_b
  (all in seconds)
docstr_tok: ["assume","the","outbound","duration","follows","duration","=","o_a","*","n","+","o_b","(","all","in","seconds",")"]
code: def __init__(self, max_latency: float):
      """
      assume the outbound duration follows duration = o_a * n + o_b
      (all in seconds)
      """
      self.o_stat: collections.deque[
          tuple[int, float, float]
      ] = collections.deque(
          maxlen=self.N_KEPT_SAMPLE
      )  # to store outbound stat data
      self.o_a = min(2, max_latency * 2.0 / 30)
      self.o_b = min(1, max_latency * 1.0 / 30)
  
      self.wait = 0  # the avg wait time before outbound called
  
      self._refresh_tb = TokenBucket(
          2
      )  # to limit params refresh interval
      self.outbound_counter = 0
  
imports: from __future__ import annotations
  import asyncio
  import collections
  import functools
  import logging
  import time
  import traceback
  import typing
  from functools import cached_property
  import attr
  import numpy
  from ..utils.alg import TokenBucket
label_desc: Use image node_id 1 to create a new Optimizer object  with example: obj = Optimizer(max_latency)