class_docstr: The standalone CPU usage metric.
  
  Instances of this metric compute the average CPU usage as a float value.
  The metric starts tracking the CPU usage when the `update` method is called
  for the first time. That is, the tracking does not start at the time the
  constructor is invoked.
  
  Calling the `update` method more than twice will update the metric to the
  average usage between the first and the last call to `update`.
  
  The result, obtained using the `result` method, is the usage computed
  as stated above.
  
  The reset method will bring the metric to its initial state. By default
  this metric in its initial state will return an usage value of 0.
class_docstr_tok: ["The","standalone","CPU","usage","metric",".","Instances","of","this","metric","compute","the","average","CPU","usage","as","a","float","value",".","The","metric","starts","tracking","the","CPU","usage","when","the","`","update","`","method","is","called","for","the","first","time",".","That","is",",","the","tracking","does","not","start","at","the","time","the","constructor","is","invoked",".","Calling","the","`","update","`","method","more","than","twice","will","update","the","metric","to","the","average","usage","between","the","first","and","the","last","call","to","`","update","`",".","The","result",",","obtained","using","the","`","result","`","method",",","is","the","usage","computed","as","stated","above",".","The","reset","method","will","bring","the","metric","to","its","initial","state",".","By","default","this","metric","in","its","initial","state","will","return","an","usage","value","of","0","."]
docstr: Update the running CPU usage.
  
  For more info on how to set the starting moment see the class
  description.
  
  :return: None.
docstr_tok: ["Update","the","running","CPU","usage",".","For","more","info","on","how","to","set","the","starting","moment","see","the","class","description",".",":","return",":","None","."]
code: def update(self) -> None:
      """
      Update the running CPU usage.
  
      For more info on how to set the starting moment see the class
      description.
  
      :return: None.
      """
      if self._first_update:
          self._process_handle = Process(os.getpid())
  
      assert self._process_handle is not None
  
      last_time = getattr(
          self._process_handle, "_last_sys_cpu_times", None
      )
      utilization = self._process_handle.cpu_percent()
      current_time = getattr(
          self._process_handle, "_last_sys_cpu_times", None
      )
  
      if self._first_update:
          self._first_update = False
      else:
          if current_time is None or last_time is None:
              warnings.warn(
                  "CPUUsage can't detect the elapsed time. It is "
                  "recommended to update avalanche to the latest "
                  "version."
              )
              # Fallback, shouldn't happen
              current_time = 1.0
              last_time = 0.0
          self._mean_usage.update(utilization, current_time - last_time)
  
imports: import os
  import warnings
  from typing import Optional, List
  from psutil import Process
  from avalanche.evaluation import Metric, PluginMetric, GenericPluginMetric
  from avalanche.evaluation.metrics import Mean
label_desc: Use image node_id 2 for calling the CPUUsage obj's underlying member method code with example usage: obj.update() without return types