class_docstr: Obsolete implementation, unused
class_docstr_tok: ["Obsolete","implementation",",","unused"]
docstr: Sample edges for one layer
  :param __current_layer_target_nodes_indexes: target nodes for current layer
  :param __top_layer_target_nodes_indexes: target nodes for top layer
  :param layer_argument: argument for current layer
  :param args: remaining positional arguments
  :param kwargs: remaining keyword arguments
  :return: (edge_id_in_integral_graph, edge_weight)
docstr_tok: ["Sample","edges","for","one","layer",":","param","__current_layer_target_nodes_indexes",":","target","nodes","for","current","layer",":","param","__top_layer_target_nodes_indexes",":","target","nodes","for","top","layer",":","param","layer_argument",":","argument","for","current","layer",":","param","args",":","remaining","positional","arguments",":","param","kwargs",":","remaining","keyword","arguments",":","return",":","(","edge_id_in_integral_graph",",","edge_weight",")"]
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 layer
      :param __current_layer_target_nodes_indexes: target nodes for current layer
      :param __top_layer_target_nodes_indexes: target nodes for top layer
      :param layer_argument: argument for current layer
      :param args: remaining positional arguments
      :param kwargs: remaining keyword arguments
      :return: (edge_id_in_integral_graph, edge_weight)
      """
      if type(layer_argument) != int:
          raise TypeError
      elif not layer_argument > 0:
          raise ValueError
      else:
          sampled_node_size_budget: int = layer_argument
  
      all_candidate_edge_indexes: torch.LongTensor = torch.cat(
          [
              torch.where(
                  self._edge_index[1] == current_target_node_index
              )[0]
              for current_target_node_index in __current_layer_target_nodes_indexes.unique().tolist()
          ]
      ).unique()
      (
          __all_candidate_source_nodes_indexes,
          all_candidate_source_nodes_probabilities,
      ) = self._Utility.get_candidate_source_nodes_probabilities(
          all_candidate_edge_indexes,
          self._edge_index,
          self.__all_edge_weights * self.__all_edge_weights,
      )
      assert (
          __all_candidate_source_nodes_indexes.size()
          == all_candidate_source_nodes_probabilities.size()
      )
  
      """ Sampling """
      if (
          sampled_node_size_budget
          < __all_candidate_source_nodes_indexes.numel()
      ):
          selected_source_node_indexes: torch.LongTensor = __all_candidate_source_nodes_indexes[
              torch.from_numpy(
                  np.unique(
                      np.random.choice(
                          np.arange(
                              __all_candidate_source_nodes_indexes.numel()
                          ),
                          sampled_node_size_budget,
                          p=all_candidate_source_nodes_probabilities.numpy(),
                          replace=False,
                      )
                  )
              ).unique()
          ].unique()
      else:
          selected_source_node_indexes: torch.LongTensor = (
              __all_candidate_source_nodes_indexes
          )
      selected_source_node_indexes: torch.LongTensor = torch.cat(
          [
              selected_source_node_indexes,
              __top_layer_target_nodes_indexes,
          ]
      ).unique()
  
      __selected_edges_indexes: torch.LongTensor = self._Utility.filter_selected_edges_by_source_nodes_and_target_nodes(
          self._edge_index,
          selected_source_node_indexes,
          __current_layer_target_nodes_indexes,
      ).unique()
  
      non_normalized_selected_edges_weight: torch.Tensor = (
          self.__all_edge_weights[__selected_edges_indexes]
          / torch.tensor(
              [
                  all_candidate_source_nodes_probabilities[
                      __all_candidate_source_nodes_indexes
                      == current_source_node_index
                  ].item()
                  for current_source_node_index in self._edge_index[
                      0, __selected_edges_indexes
                  ].tolist()
              ]
          )
      )
  
      def __normalize_edges_weight_by_target_nodes(
          __edge_index: torch.Tensor, __edge_weight: torch.Tensor
      ) -> torch.Tensor:
          if __edge_index.size(1) != __edge_weight.numel():
              raise ValueError
          for current_target_node_index in (
              __edge_index[1].unique().tolist()
          ):
              __current_mask_for_edges: torch.BoolTensor = (
                  __edge_index[1] == current_target_node_index
              )
              __edge_weight[__current_mask_for_edges] = __edge_weight[
                  __current_mask_for_edges
              ] / torch.sum(__edge_weight[__current_mask_for_edges])
          return __edge_weight
  
      normalized_selected_edges_weight: torch.Tensor = (
          __normalize_edges_weight_by_target_nodes(
              self._edge_index[:, __selected_edges_indexes],
              non_normalized_selected_edges_weight,
          )
      )
      return __selected_edges_indexes, normalized_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 2 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: __selected_edges_indexes,  normalized_selected_edges_weight, __edge_weight