code: def model_stats2df(model_stats: ModelStats):
      pd.set_option("display.width", 1000)
      pd.set_option("display.max_rows", 10000)
      pd.set_option("display.max_columns", 10000)
  
      df = pd.DataFrame([l.__dict__ for l in model_stats.layer_stats])
      total_df = pd.Series(model_stats.__dict__, name="Total")
      df = df.append(total_df[df.columns], ignore_index=True)
  
      df = df.fillna(" ")
      # df['memory(MB)'] = df['memory(MB)'].apply(
      #     lambda x: '{:.2f}'.format(x))
      # df['duration[%]'] = df['duration[%]'].apply(lambda x: '{:.2%}'.format(x))
      for c in [
          "MAdd",
          "Flops",
          "parameters",
          "inference_memory",
          "mread",
          "mwrite",
      ]:
          df[c] = df[c].apply(lambda x: "{:,}".format(x))
  
      df.rename(
          columns={
              "name": "module name",
              "input_shape": "input shape",
              "output_shape": "output shape",
              "inference_memory": "infer memory(MB)",
              "mread": "MemRead(B)",
              "mwrite": "MemWrite(B)",
          },
          inplace=True,
      )
  
      # summary = "Total params: {:,}\n".format(total_parameters_quantity)
  
      # summary += "-" * len(str(df).split('\n')[0])
      # summary += '\n'
      # summary += "Total memory: {:.2f}MB\n".format(total_memory)
      # summary += "Total MAdd: {}MAdd\n".format(_round_value(total_operation_quantity))
      # summary += "Total Flops: {}Flops\n".format(_round_value(total_flops))
      # summary += "Total MemR+W: {}B\n".format(_round_value(total_memrw, True))
      return df
  
file_path: tensorwatch/tensorwatch/model_graph/torchstat_utils.py
imports: from .torchstat import analyzer
  import pandas
  import copy
label_desc: Use image node_id 3 for calling a global function with example usage: model_stats2df(model_stats) and returns: df