docstr: Creates a summary of a :class:`~torch_geometric.data.Dataset`
  object.
  
  Args:
      dataset (Dataset): The dataset.
      progress_bar (bool, optional): If set to :obj:`True`, will show a
          progress bar during stats computation. If set to :obj:`None`,
          will automatically decide whether to show a progress bar based
          on dataset size. (default: :obj:`None`)
      per_type (bool, optional): If set to :obj:`True`, will separate
          statistics per node and edge type (only applicable in
          heterogeneous graph datasets). (default: :obj:`True`)
docstr_tok: ["Creates","a","summary","of","a",":","class",":","`","~torch_geometric.data.Dataset","`","object",".","Args",":","dataset","(","Dataset",")",":","The","dataset",".","progress_bar","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","True","`",",","will","show","a","progress","bar","during","stats","computation",".","If","set","to",":","obj",":","`","None","`",",","will","automatically","decide","whether","to","show","a","progress","bar","based","on","dataset","size",".","(","default",":",":","obj",":","`","None","`",")","per_type","(","bool",",","optional",")",":","If","set","to",":","obj",":","`","True","`",",","will","separate","statistics","per","node","and","edge","type","(","only","applicable","in","heterogeneous","graph","datasets",")",".","(","default",":",":","obj",":","`","True","`",")"]
code: def from_dataset(
      cls,
      dataset: Dataset,
      progress_bar: Optional[bool] = None,
      per_type: bool = True,
  ) -> Self:
      r"""Creates a summary of a :class:`~torch_geometric.data.Dataset`
      object.
  
      Args:
          dataset (Dataset): The dataset.
          progress_bar (bool, optional): If set to :obj:`True`, will show a
              progress bar during stats computation. If set to :obj:`None`,
              will automatically decide whether to show a progress bar based
              on dataset size. (default: :obj:`None`)
          per_type (bool, optional): If set to :obj:`True`, will separate
              statistics per node and edge type (only applicable in
              heterogeneous graph datasets). (default: :obj:`True`)
      """
      name = dataset.__class__.__name__
  
      if progress_bar is None:
          progress_bar = len(dataset) >= 10000
  
      if progress_bar:
          dataset = tqdm(dataset)
  
      num_nodes, num_edges = [], []
      _num_nodes_per_type = defaultdict(list)
      _num_edges_per_type = defaultdict(list)
  
      for data in dataset:
          assert data.num_nodes is not None
          num_nodes.append(data.num_nodes)
          num_edges.append(data.num_edges)
  
          if per_type and isinstance(data, HeteroData):
              for node_type in data.node_types:
                  _num_nodes_per_type[node_type].append(
                      data[node_type].num_nodes
                  )
              for edge_type in data.edge_types:
                  _num_edges_per_type[edge_type].append(
                      data[edge_type].num_edges
                  )
  
      num_nodes_per_type = None
      if len(_num_nodes_per_type) > 0:
          num_nodes_per_type = {
              node_type: Stats.from_data(num_nodes_list)
              for node_type, num_nodes_list in _num_nodes_per_type.items()
          }
  
      num_edges_per_type = None
      if len(_num_edges_per_type) > 0:
          num_edges_per_type = {
              edge_type: Stats.from_data(num_edges_list)
              for edge_type, num_edges_list in _num_edges_per_type.items()
          }
  
      return cls(
          name=name,
          num_graphs=len(dataset),
          num_nodes=Stats.from_data(num_nodes),
          num_edges=Stats.from_data(num_edges),
          num_nodes_per_type=num_nodes_per_type,
          num_edges_per_type=num_edges_per_type,
      )
  
file_path: pytorch_geometric/torch_geometric/data/summary.py
imports: from collections import defaultdict
  from dataclasses import dataclass
  from typing import Dict, List, Optional, Union
  import torch
  from tqdm import tqdm
  from typing_extensions import Self
  from torch_geometric.data import Dataset, HeteroData
  from torch_geometric.typing import EdgeType, NodeType
label_desc: Use image node_id 1 for calling the Summary obj's underlying member method code with example usage: obj.from_dataset(cls, dataset, progress_bar, per_type) and returns: cls