class_docstr: The layer-dependent importance sampler from the
  `"Layer-Dependent Importance Sampling for Training Deep and Large Graph Convolutional Networks"
  <https://arxiv.org/abs/1911.07323>`_ literature,  which allows
  for mini-batch training of GNNs on large-scale graphs where full-batch training is not feasible.
  
  Arguments
  ------------
  edge_index:
      A :obj:`torch.LongTensor` that defines the underlying graph
      connectivity/message passing flow.
      :obj:`edge_index` holds the indices of a (sparse) adjacency matrix.
      If :obj:`edge_index` is of type :obj:`torch.LongTensor`, its shape
      must be defined as :obj:`[2, num_edges]`, where messages from nodes
      :obj:`edge_index[0]` are sent to nodes in :obj:`edge_index[1]`
      (in case :obj:`flow="source_to_target"`).
  target_nodes_indexes:
      indexes of target nodes to learn representation.
  layer_wise_arguments:
      The number of nodes to sample for each layer.
      It's noteworthy that the target nodes for a specific layer
      always be preserved as source nodes for that layer,
      such that the self loops for those target nodes
      are generally preserved for representation learning.
  batch_size:
      number of target nodes for each mini-batch.
  num_workers:
      num_workers argument for inner :class:`torch.utils.data.DataLoader`
  shuffle:
      whether to shuffle target nodes for mini-batches.
class_docstr_tok: ["The","layer-dependent","importance","sampler","from","the","`","``","Layer-Dependent","Importance","Sampling","for","Training","Deep","and","Large","Graph","Convolutional","Networks","''","<","https",":","\/\/arxiv.org\/abs\/1911.07323",">","`","_","literature",",","which","allows","for","mini-batch","training","of","GNNs","on","large-scale","graphs","where","full-batch","training","is","not","feasible",".","Arguments","--","--","--","--","--","--","edge_index",":","A",":","obj",":","`","torch.LongTensor","`","that","defines","the","underlying","graph","connectivity\/message","passing","flow",".",":","obj",":","`","edge_index","`","holds","the","indices","of","a","(","sparse",")","adjacency","matrix",".","If",":","obj",":","`","edge_index","`","is","of","type",":","obj",":","`","torch.LongTensor","`",",","its","shape","must","be","defined","as",":","obj",":","`","[","2",",","num_edges","]","`",",","where","messages","from","nodes",":","obj",":","`","edge_index","[","0","]","`","are","sent","to","nodes","in",":","obj",":","`","edge_index","[","1","]","`","(","in","case",":","obj",":","`","flow=","''","source_to_target","''","`",")",".","target_nodes_indexes",":","indexes","of","target","nodes","to","learn","representation",".","layer_wise_arguments",":","The","number","of","nodes","to","sample","for","each","layer",".","It","'s","noteworthy","that","the","target","nodes","for","a","specific","layer","always","be","preserved","as","source","nodes","for","that","layer",",","such","that","the","self","loops","for","those","target","nodes","are","generally","preserved","for","representation","learning",".","batch_size",":","number","of","target","nodes","for","each","mini-batch",".","num_workers",":","num_workers","argument","for","inner",":","class",":","`","torch.utils.data.DataLoader","`","shuffle",":","whether","to","shuffle","target","nodes","for","mini-batches","."]
docstr: Sample edges for one specific layer, expected to be implemented in subclass.
  
  Parameters
  ------------
  __current_layer_target_nodes_indexes:
      target nodes for current layer
  __top_layer_target_nodes_indexes:
      target nodes for top layer
  layer_argument:
      argument for current layer
  args:
      remaining positional arguments
  kwargs:
      remaining keyword arguments
  
  Returns
  --------
  edge_id_in_integral_graph:
      the corresponding positional indexes for the `edge_index` of integral graph
  edge_weight:
      the optional `edge_weight` for aggregation
docstr_tok: ["Sample","edges","for","one","specific","layer",",","expected","to","be","implemented","in","subclass",".","Parameters","--","--","--","--","--","--","__current_layer_target_nodes_indexes",":","target","nodes","for","current","layer","__top_layer_target_nodes_indexes",":","target","nodes","for","top","layer","layer_argument",":","argument","for","current","layer","args",":","remaining","positional","arguments","kwargs",":","remaining","keyword","arguments","Returns","--","--","--","--","edge_id_in_integral_graph",":","the","corresponding","positional","indexes","for","the","`","edge_index","`","of","integral","graph","edge_weight",":","the","optional","`","edge_weight","`","for","aggregation"]
code: def _sample_edges_for_layer(
      self,
      __current_layer_target_nodes_indexes: torch.LongTensor,
      __top_layer_target_nodes_indexes: torch.LongTensor,
      layer_argument: _typing.Any,
      *args,
      **kwargs,
  ) -> _typing.Tuple[torch.LongTensor, _typing.Optional[torch.Tensor]]:
      """
      Sample edges for one specific layer, expected to be implemented in subclass.
  
      Parameters
      ------------
      __current_layer_target_nodes_indexes:
          target nodes for current layer
      __top_layer_target_nodes_indexes:
          target nodes for top layer
      layer_argument:
          argument for current layer
      args:
          remaining positional arguments
      kwargs:
          remaining keyword arguments
  
      Returns
      --------
      edge_id_in_integral_graph:
          the corresponding positional indexes for the `edge_index` of integral graph
      edge_weight:
          the optional `edge_weight` for aggregation
      """
      __wrapped_result: _typing.Tuple[
          np.ndarray, np.ndarray, np.ndarray
      ] = self.__sample_edges(
          __current_layer_target_nodes_indexes.numpy(),
          __top_layer_target_nodes_indexes.numpy(),
          layer_argument,
      )
      _sampled_edges_indexes: torch.Tensor = torch.from_numpy(
          __wrapped_result[0]
      )
      _selected_source_nodes: torch.Tensor = torch.from_numpy(
          __wrapped_result[1]
      )
      _selected_source_nodes_probabilities: torch.Tensor = (
          torch.from_numpy(__wrapped_result[2])
      )
  
      """ Multiply corresponding discount weights """
      __selected_source_node_probability_mapping: _typing.Dict[
          int, float
      ] = dict(
          zip(
              _selected_source_nodes.tolist(),
              _selected_source_nodes_probabilities.tolist(),
          )
      )
      _selected_edges_weight: torch.Tensor = self.__edge_weight[
          _sampled_edges_indexes
      ]
      _selected_edges_weight: torch.Tensor = (
          _selected_edges_weight
          / torch.tensor(
              [
                  __selected_source_node_probability_mapping.get(
                      _current_source_node_index
                  )
                  for _current_source_node_index in self._edge_index[
                      0, _sampled_edges_indexes
                  ].tolist()
              ]
          )
      )
  
      """ Normalize edge weight for selected edges by target nodes """
      for _current_target_node_index in (
          self._edge_index[1, _sampled_edges_indexes].unique().tolist()
      ):
          _current_mask_for_selected_edges: torch.BoolTensor = (
              self._edge_index[1, _sampled_edges_indexes]
              == _current_target_node_index
          )
          _selected_edges_weight[
              _current_mask_for_selected_edges
          ] = _selected_edges_weight[
              _current_mask_for_selected_edges
          ] / torch.sum(
              _selected_edges_weight[_current_mask_for_selected_edges]
          )
  
      _sampled_edges_indexes: _typing.Union[
          torch.LongTensor, torch.Tensor
      ] = _sampled_edges_indexes
      return _sampled_edges_indexes, _selected_edges_weight
  
file_path: AutoGL/autogl/module/train/sampling/sampler/layer_dependent_importance_sampler.py
imports: import numpy
  import scipy.sparse
  import torch
  import torch.utils.data
  import typing
  import torch_geometric
  from .None import target_dependant_sampler
label_desc: Use image node_id 4 for calling the LayerDependentImportanceSampler obj's underlying member method code with example usage: obj._sample_edges_for_layer(__current_layer_target_nodes_indexes, __top_layer_target_nodes_indexes, layer_argument) and returns: _sampled_edges_indexes,  _selected_edges_weight