class_docstr: Analyse historical data to optimize CorkDispatcher.
class_docstr_tok: ["Analyse","historical","data","to","optimize","CorkDispatcher","."]
code: def trigger_refresh(self):
      if not self.o_stat:
          logger.debug(
              "o_stat is empty, skip dynamic batching optimizer params update"
          )
          return
  
      x = tuple((i, 1) for i, _, _ in self.o_stat)
      y = tuple(i for _, i, _ in self.o_stat)
  
      _factors: tuple[float, float] = np.linalg.lstsq(x, y, rcond=None)[0]  # type: ignore
      _o_a, _o_b = _factors
      _o_w = sum(w for _, _, w in self.o_stat) * 1.0 / len(self.o_stat)
  
      self.o_a, self.o_b = max(0.000001, _o_a), max(0, _o_b)
      self.wait = max(0, _o_w)
      logger.debug(
          "Dynamic batching optimizer params updated: o_a: %.6f, o_b: %.6f, wait: %.6f",
          _o_a,
          _o_b,
          _o_w,
      )
  
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 3 for calling the Optimizer obj's underlying member method code with example usage: obj.trigger_refresh() without return types