docstr: Run whenever a task changes state
  
  Parameters
  ----------
  key : string
  start : string
      Start state of the transition.
      One of released, waiting, processing, memory, error.
  finish : string
      Final state of the transition.
  stimulus_id: string
      ID of stimulus causing the transition.
  *args, **kwargs : More options passed when transitioning
      This may include worker ID, compute time, etc.
docstr_tok: ["Run","whenever","a","task","changes","state","Parameters","--","--","--","--","--","key",":","string","start",":","string","Start","state","of","the","transition",".","One","of","released",",","waiting",",","processing",",","memory",",","error",".","finish",":","string","Final","state","of","the","transition",".","stimulus_id",":","string","ID","of","stimulus","causing","the","transition",".","*","args",",","*","*","kwargs",":","More","options","passed","when","transitioning","This","may","include","worker","ID",",","compute","time",",","etc","."]
code: def transition(self, key, start, finish, *args, **kwargs):
      """Run whenever a task changes state
  
      Parameters
      ----------
      key : string
      start : string
          Start state of the transition.
          One of released, waiting, processing, memory, error.
      finish : string
          Final state of the transition.
      stimulus_id: string
          ID of stimulus causing the transition.
      *args, **kwargs : More options passed when transitioning
          This may include worker ID, compute time, etc.
      """
      if key not in self.scheduler.tasks:
          return
      kwargs["key"] = key
      startstops = kwargs.get("startstops", [])
      for startstop in startstops:
          color = colors[startstop["action"]]
          if type(color) is not str:
              color = color(kwargs)
          data = {
              "key": key,
              "name": key_split(key),
              "color": color,
              **kwargs,
              **startstop,
          }
          self.socket.send("transition", data)
  
file_path: distributed/distributed/diagnostics/websocket.py
imports: from __future__ import annotations
  from dask.utils import key_split
  from distributed.diagnostics.plugin import SchedulerPlugin
  from distributed.diagnostics.task_stream import colors
label_desc: Use image node_id 8 for calling the WebsocketPlugin obj's underlying member method code with example usage: obj.transition(key, start, finish) without return types