class_docstr: A decorator around `nn.Module` that allows a module and its ancestors to collect and report metrics, such
  as accuracy, loss, etc.
  
  Each Module can collect arbitrary metrics in its fields. The Module implementors should initialize
  and update the metrics as they see fit. Implementors should define
   * `_reset_module_metrics` that resets the module metrics (e.g. sets a counter to zero)
   * `_module_metrics` that reports a dictionary of metrics for this specific module.
  
  `ModuleWithMetrics` can recursively collect all the metrics from its children and report it
  by invoking `report_metrics()`. Metrics are automatically reset when `train()` or `eval()`
  is invoked.
class_docstr_tok: ["A","decorator","around","`","nn.Module","`","that","allows","a","module","and","its","ancestors","to","collect","and","report","metrics",",","such","as","accuracy",",","loss",",","etc",".","Each","Module","can","collect","arbitrary","metrics","in","its","fields",".","The","Module","implementors","should","initialize","and","update","the","metrics","as","they","see","fit",".","Implementors","should","define","*","`","_reset_module_metrics","`","that","resets","the","module","metrics","(","e.g",".","sets","a","counter","to","zero",")","*","`","_module_metrics","`","that","reports","a","dictionary","of","metrics","for","this","specific","module",".","`","ModuleWithMetrics","`","can","recursively","collect","all","the","metrics","from","its","children","and","report","it","by","invoking","`","report_metrics","(",")","`",".","Metrics","are","automatically","reset","when","`","train","(",")","`","or","`","eval","(",")","`","is","invoked","."]
docstr: Report the collected metrics for this `ModuleWithMetrics` and its descendant modules.
  
  Each module can internally collect its own metrics as the implementor sees fit. For example,
  a counter may be incremented when the `forward()` function is invoked or a running average may
  by updated when a loss is computed. The metrics counter can be reset outside of the module
  when `reset_metrics` is invoked.
  
  To add metrics to a Module, implementors need to:
  * Implement `_module_metrics` that computes the reported metrics from any component-internal variables.
  * Implement `_reset_module_metrics` which resets any variables that compute metrics.
  * Store any metric-related variables as fields in the module.
docstr_tok: ["Report","the","collected","metrics","for","this","`","ModuleWithMetrics","`","and","its","descendant","modules",".","Each","module","can","internally","collect","its","own","metrics","as","the","implementor","sees","fit",".","For","example",",","a","counter","may","be","incremented","when","the","`","forward","(",")","`","function","is","invoked","or","a","running","average","may","by","updated","when","a","loss","is","computed",".","The","metrics","counter","can","be","reset","outside","of","the","module","when","`","reset_metrics","`","is","invoked",".","To","add","metrics","to","a","Module",",","implementors","need","to",":","*","Implement","`","_module_metrics","`","that","computes","the","reported","metrics","from","any","component-internal","variables",".","*","Implement","`","_reset_module_metrics","`","which","resets","any","variables","that","compute","metrics",".","*","Store","any","metric-related","variables","as","fields","in","the","module","."]
code: def report_metrics(self) -> Dict[str, Any]:
      """
      Report the collected metrics for this `ModuleWithMetrics` and its descendant modules.
  
      Each module can internally collect its own metrics as the implementor sees fit. For example,
      a counter may be incremented when the `forward()` function is invoked or a running average may
      by updated when a loss is computed. The metrics counter can be reset outside of the module
      when `reset_metrics` is invoked.
  
      To add metrics to a Module, implementors need to:
      * Implement `_module_metrics` that computes the reported metrics from any component-internal variables.
      * Implement `_reset_module_metrics` which resets any variables that compute metrics.
      * Store any metric-related variables as fields in the module.
      """
      metrics = self._module_metrics()
      for child_module in self.modules():
          if isinstance(child_module, ModuleWithMetrics):
              child_metrics = child_module._module_metrics()
              if len(child_metrics) > 0:
                  metrics.update(child_metrics)
      return metrics
  
file_path: ptgnn/ptgnn/baseneuralmodel/modulewithmetrics.py
imports: from typing_extensions import final
  from abc import ABC
  from torch import nn
  from typing import Any, Dict
label_desc: Use image node_id 2 for calling the ModuleWithMetrics obj's underlying member method code with example usage: obj.report_metrics() and returns: metrics