class_docstr: Combines one or more aggregators and transforms its output with one or
  more scalers as introduced in the `"Principal Neighbourhood Aggregation for
  Graph Nets" <https://arxiv.org/abs/2004.05718>`_ paper.
  The scalers are normalised by the in-degree of the training set and so must
  be provided at time of construction.
  See :class:`torch_geometric.nn.conv.PNAConv` for more information.
  
  Args:
      aggr (str or [str] or Aggregation): The aggregation scheme to use.
          See :class:`~torch_geometric.nn.conv.MessagePassing` for more
          information.
      scaler (str or list): Set of scaling function identifiers, namely one
          or more of :obj:`"identity"`, :obj:`"amplification"`,
          :obj:`"attenuation"`, :obj:`"linear"` and :obj:`"inverse_linear"`.
      deg (Tensor): Histogram of in-degrees of nodes in the training set,
          used by scalers to normalize.
      train_norm (bool, optional): Whether normalization parameters
          are trainable. (default: :obj:`False`)
      aggr_kwargs (Dict[str, Any], optional): Arguments passed to the
          respective aggregation function in case it gets automatically
          resolved. (default: :obj:`None`)
class_docstr_tok: ["Combines","one","or","more","aggregators","and","transforms","its","output","with","one","or","more","scalers","as","introduced","in","the","`","``","Principal","Neighbourhood","Aggregation","for","Graph","Nets","''","<","https",":","\/\/arxiv.org\/abs\/2004.05718",">","`","_","paper",".","The","scalers","are","normalised","by","the","in-degree","of","the","training","set","and","so","must","be","provided","at","time","of","construction",".","See",":","class",":","`","torch_geometric.nn.conv.PNAConv","`","for","more","information",".","Args",":","aggr","(","str","or","[","str","]","or","Aggregation",")",":","The","aggregation","scheme","to","use",".","See",":","class",":","`","~torch_geometric.nn.conv.MessagePassing","`","for","more","information",".","scaler","(","str","or","list",")",":","Set","of","scaling","function","identifiers",",","namely","one","or","more","of",":","obj",":","`","``","identity","''","`",",",":","obj",":","`","``","amplification","''","`",",",":","obj",":","`","``","attenuation","''","`",",",":","obj",":","`","``","linear","''","`","and",":","obj",":","`","``","inverse_linear","''","`",".","deg","(","Tensor",")",":","Histogram","of","in-degrees","of","nodes","in","the","training","set",",","used","by","scalers","to","normalize",".","train_norm","(","bool",",","optional",")",":","Whether","normalization","parameters","are","trainable",".","(","default",":",":","obj",":","`","False","`",")","aggr_kwargs","(","Dict","[","str",",","Any","]",",","optional",")",":","Arguments","passed","to","the","respective","aggregation","function","in","case","it","gets","automatically","resolved",".","(","default",":",":","obj",":","`","None","`",")"]
code: def __init__(
      self,
      aggr: Union[str, List[str], Aggregation],
      scaler: Union[str, List[str]],
      deg: Tensor,
      train_norm: bool = False,
      aggr_kwargs: Optional[List[Dict[str, Any]]] = None,
  ):
      super().__init__()
  
      if isinstance(aggr, (str, Aggregation)):
          self.aggr = aggr_resolver(aggr, **(aggr_kwargs or {}))
      elif isinstance(aggr, (tuple, list)):
          self.aggr = MultiAggregation(aggr, aggr_kwargs)
      else:
          raise ValueError(
              f"Only strings, list, tuples and instances of"
              f"`torch_geometric.nn.aggr.Aggregation` are "
              f"valid aggregation schemes (got '{type(aggr)}')"
          )
  
      self.scaler = [scaler] if isinstance(aggr, str) else scaler
  
      deg = deg.to(torch.float)
      N = int(deg.sum())
      bin_degree = torch.arange(deg.numel(), device=deg.device)
  
      self.init_avg_deg_lin = float((bin_degree * deg).sum()) / N
      self.init_avg_deg_log = (
          float(((bin_degree + 1).log() * deg).sum()) / N
      )
  
      if train_norm:
          self.avg_deg_lin = torch.nn.Parameter(torch.empty(1))
          self.avg_deg_log = torch.nn.Parameter(torch.empty(1))
      else:
          self.register_buffer("avg_deg_lin", torch.empty(1))
          self.register_buffer("avg_deg_log", torch.empty(1))
  
      self.reset_parameters()
  
file_path: pytorch_geometric/torch_geometric/nn/aggr/scaler.py
imports: from typing import Any, Dict, List, Optional, Union
  import torch
  from torch import Tensor
  from torch_geometric.nn.aggr import Aggregation, MultiAggregation
  from torch_geometric.nn.resolver import aggregation_resolver
  from torch_geometric.utils import degree
label_desc: Use image node_id 1 to create a new DegreeScalerAggregation object from inherited base classes: Aggregation with example: obj = DegreeScalerAggregation(aggr, scaler, deg, train_norm, aggr_kwargs)