class_docstr: An implementation of a distributed and asynchronised neighbor sampler
  used by :class:`~torch_geometric.distributed.DistNeighborLoader`.
class_docstr_tok: ["An","implementation","of","a","distributed","and","asynchronised","neighbor","sampler","used","by",":","class",":","`","~torch_geometric.distributed.DistNeighborLoader","`","."]
docstr: Merges samplers outputs from different partitions, so that they
  are sorted according to the sampling order. Removes seed nodes from
  sampled nodes and calculates how many neighbors were sampled by each
  src node based on the :obj:`cumsum_neighbors_per_node`. Leverages the
  :obj:`pyg-lib` :obj:`merge_sampler_outputs` function.
  
  Args:
      partition_ids (torch.Tensor): Contains information on which
          partition seeds nodes are located on.
      partition_orders (torch.Tensor): Contains information about the
          order of seed nodes in each partition.
      outputs (List[SamplerOutput]): List of all samplers outputs.
      one_hop_num (int): Max number of neighbors sampled in the current
          layer.
      src_batch (torch.Tensor, optional): The batch assignment of seed
          nodes. (default: :obj:`None`)
  
  Returns :obj:`SamplerOutput` containing all merged outputs.
docstr_tok: ["Merges","samplers","outputs","from","different","partitions",",","so","that","they","are","sorted","according","to","the","sampling","order",".","Removes","seed","nodes","from","sampled","nodes","and","calculates","how","many","neighbors","were","sampled","by","each","src","node","based","on","the",":","obj",":","`","cumsum_neighbors_per_node","`",".","Leverages","the",":","obj",":","`","pyg-lib","`",":","obj",":","`","merge_sampler_outputs","`","function",".","Args",":","partition_ids","(","torch.Tensor",")",":","Contains","information","on","which","partition","seeds","nodes","are","located","on",".","partition_orders","(","torch.Tensor",")",":","Contains","information","about","the","order","of","seed","nodes","in","each","partition",".","outputs","(","List","[","SamplerOutput","]",")",":","List","of","all","samplers","outputs",".","one_hop_num","(","int",")",":","Max","number","of","neighbors","sampled","in","the","current","layer",".","src_batch","(","torch.Tensor",",","optional",")",":","The","batch","assignment","of","seed","nodes",".","(","default",":",":","obj",":","`","None","`",")","Returns",":","obj",":","`","SamplerOutput","`","containing","all","merged","outputs","."]
code: def merge_sampler_outputs(
      self,
      partition_ids: Tensor,
      partition_orders: Tensor,
      outputs: List[SamplerOutput],
      one_hop_num: int,
      src_batch: Optional[Tensor] = None,
  ) -> SamplerOutput:
      r"""Merges samplers outputs from different partitions, so that they
      are sorted according to the sampling order. Removes seed nodes from
      sampled nodes and calculates how many neighbors were sampled by each
      src node based on the :obj:`cumsum_neighbors_per_node`. Leverages the
      :obj:`pyg-lib` :obj:`merge_sampler_outputs` function.
  
      Args:
          partition_ids (torch.Tensor): Contains information on which
              partition seeds nodes are located on.
          partition_orders (torch.Tensor): Contains information about the
              order of seed nodes in each partition.
          outputs (List[SamplerOutput]): List of all samplers outputs.
          one_hop_num (int): Max number of neighbors sampled in the current
              layer.
          src_batch (torch.Tensor, optional): The batch assignment of seed
              nodes. (default: :obj:`None`)
  
      Returns :obj:`SamplerOutput` containing all merged outputs.
      """
      sampled_nodes_with_dupl = [
          o.node if o is not None else torch.empty(0, dtype=torch.int64)
          for o in outputs
      ]
      edge_ids = [
          o.edge if o is not None else torch.empty(0, dtype=torch.int64)
          for o in outputs
      ]
      cumm_sampled_nbrs_per_node = [
          o.metadata[0] if o is not None else [] for o in outputs
      ]
  
      partition_ids = partition_ids.tolist()
      partition_orders = partition_orders.tolist()
  
      partitions_num = self.graph_store.meta["num_parts"]
  
      out = torch.ops.pyg.merge_sampler_outputs(
          sampled_nodes_with_dupl,
          edge_ids,
          cumm_sampled_nbrs_per_node,
          partition_ids,
          partition_orders,
          partitions_num,
          one_hop_num,
          src_batch,
          self.disjoint,
      )
      (
          out_node_with_dupl,
          out_edge,
          out_batch,
          out_sampled_nbrs_per_node,
      ) = out
  
      return SamplerOutput(
          out_node_with_dupl,
          None,
          None,
          out_edge,
          out_batch if self.disjoint else None,
          metadata=(out_sampled_nbrs_per_node,),
      )
  
imports: import itertools
  import logging
  import math
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.multiprocessing
  from torch import Tensor
  from torch_geometric.distributed import LocalFeatureStore, LocalGraphStore
  from torch_geometric.distributed.dist_context import DistContext
  from torch_geometric.distributed.event_loop import ConcurrentEventLoop, to_asyncio_future
  from torch_geometric.distributed.rpc import RPCCallBase, RPCRouter, rpc_async, rpc_partition_to_workers, rpc_register
  from torch_geometric.distributed.utils import BatchDict, NodeDict, remove_duplicates
  from torch_geometric.sampler import EdgeSamplerInput, HeteroSamplerOutput, NegativeSampling, NeighborSampler, NodeSamplerInput, SamplerOutput
  from torch_geometric.sampler.base import NumNeighbors, SubgraphType
  from torch_geometric.sampler.neighbor_sampler import neg_sample
  from torch_geometric.sampler.utils import remap_keys
  from torch_geometric.typing import EdgeType, NodeType
label_desc: Use image node_id 8 for calling the DistNeighborSampler obj's underlying member method code with example usage: obj.merge_sampler_outputs(partition_ids, partition_orders, outputs, one_hop_num, src_batch) and returns: SamplerOutput