class_docstr: The standalone RAM usage metric.
  
  Important: this metric approximates the real maximum RAM usage since
  it sample at discrete amount of time the RAM values.
  
  Instances of this metric keeps the maximum RAM usage detected.
  The `start_thread` method starts the usage tracking.
  The `stop_thread` method stops the tracking.
  
  The result, obtained using the `result` method, is the usage in mega-bytes.
  
  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","RAM","usage","metric",".","Important",":","this","metric","approximates","the","real","maximum","RAM","usage","since","it","sample","at","discrete","amount","of","time","the","RAM","values",".","Instances","of","this","metric","keeps","the","maximum","RAM","usage","detected",".","The","`","start_thread","`","method","starts","the","usage","tracking",".","The","`","stop_thread","`","method","stops","the","tracking",".","The","result",",","obtained","using","the","`","result","`","method",",","is","the","usage","in","mega-bytes",".","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: Until a stop signal is encountered,
  this function monitors each `every` seconds
  the maximum amount of RAM used by the process
docstr_tok: ["Until","a","stop","signal","is","encountered",",","this","function","monitors","each","`","every","`","seconds","the","maximum","amount","of","RAM","used","by","the","process"]
code: def _f(self):
      """
      Until a stop signal is encountered,
      this function monitors each `every` seconds
      the maximum amount of RAM used by the process
      """
      start_time = time.monotonic()
      while not self.stop_f:
          # ram usage in MB
          ram_usage = (
              self._process_handle.memory_info().rss / 1024 / 1024
          )
          if ram_usage > self.max_usage:
              self.max_usage = ram_usage
          time.sleep(
              self.every
              - ((time.monotonic() - start_time) % self.every)
          )
  
imports: import os
  import time
  from typing import Optional, List, TYPE_CHECKING
  from threading import Thread
  from psutil import Process
  from avalanche.evaluation import Metric, PluginMetric, GenericPluginMetric
  from avalanche.evaluation.metric_results import MetricResult
label_desc: Use image node_id 2 for calling the MaxRAM obj's underlying member method code with example usage: obj._f() without return types