docstr: Returns the profiled statistics as a dictionary.
  
  Parameters
  ----------
  by_type: bool
      Whether to return the statistics by module type. If ``False``, the statistics
      are returned by module name. If ``True``, the statistics are returned by module
      type.
docstr_tok: ["Returns","the","profiled","statistics","as","a","dictionary",".","Parameters","--","--","--","--","--","by_type",":","bool","Whether","to","return","the","statistics","by","module","type",".","If","``","False","``",",","the","statistics","are","returned","by","module","name",".","If","``","True","``",",","the","statistics","are","returned","by","module","type","."]
code: def as_dict(
      self, by_type=False
  ) -> Dict[str, Dict[str, Union[int, None]]]:
      """
      Returns the profiled statistics as a dictionary.
  
      Parameters
      ----------
      by_type: bool
          Whether to return the statistics by module type. If ``False``, the statistics
          are returned by module name. If ``True``, the statistics are returned by module
          type.
      """
      if by_type:
          ret = {"flops": {}, "params": {}}
          for node in self.module.graph.nodes:
              node: Node
              if node.op == "call_module":
                  module = self.fetch_attr(node.target)
                  if type(module).__name__ not in ret["flops"]:
                      ret["flops"][type(module).__name__] = 0
                  if type(module) not in ret["params"]:
                      ret["params"][type(module).__name__] = 0
                  ret["flops"][type(module).__name__] += NInfo(
                      node
                  ).flops
                  ret["params"][type(module).__name__] += NInfo(
                      node
                  ).param_size
          return ret
      else:
          return {
              "flops": {
                  node.name: NInfo(node).flops
                  for node in self.module.graph.nodes
                  if node.op == "call_module"
              },
              "params": {
                  node.name: NInfo(node).param_size
                  for node in self.module.graph.nodes
                  if node.op == "call_module"
              },
          }
  
imports: from typing import Any, Callable, Dict, List, Tuple, Optional, Union
  from dataclasses import dataclass, field
  import torch
  import torch.fx
  from torch.fx import Interpreter
  from torch.fx.node import Argument, Node
  from .flop_utils import flop_count
label_desc: Use image node_id 7 for calling the GraphCounter obj's underlying member method code with example usage: obj.as_dict(by_type) and returns: ret, dict