class_docstr: SAGE model for distributed train and evaluation.
  
  Parameters
  ----------
  in_feats : int
      Feature dimension.
  n_hidden : int
      Hidden layer dimension.
  n_classes : int
      Number of classes.
  n_layers : int
      Number of layers.
  activation : callable
      Activation function.
  dropout : float
      Dropout value.
class_docstr_tok: ["SAGE","model","for","distributed","train","and","evaluation",".","Parameters","--","--","--","--","--","in_feats",":","int","Feature","dimension",".","n_hidden",":","int","Hidden","layer","dimension",".","n_classes",":","int","Number","of","classes",".","n_layers",":","int","Number","of","layers",".","activation",":","callable","Activation","function",".","dropout",":","float","Dropout","value","."]
docstr: Distributed layer-wise inference with the GraphSAGE model on full
  neighbors.
  
  Parameters
  ----------
  g : DistGraph
      Input Graph for inference.
  x : DistTensor
      Node feature data of input graph.
  
  Returns
  -------
  DistTensor
      Inference results.
docstr_tok: ["Distributed","layer-wise","inference","with","the","GraphSAGE","model","on","full","neighbors",".","Parameters","--","--","--","--","--","g",":","DistGraph","Input","Graph","for","inference",".","x",":","DistTensor","Node","feature","data","of","input","graph",".","Returns","--","--","--","-","DistTensor","Inference","results","."]
code: def inference(self, g, x, batch_size, device):
      """
      Distributed layer-wise inference with the GraphSAGE model on full
      neighbors.
  
      Parameters
      ----------
      g : DistGraph
          Input Graph for inference.
      x : DistTensor
          Node feature data of input graph.
  
      Returns
      -------
      DistTensor
          Inference results.
      """
      # Split nodes to each trainer.
      nodes = dgl.distributed.node_split(
          np.arange(g.num_nodes()),
          g.get_partition_book(),
          force_even=True,
      )
  
      for i, layer in enumerate(self.layers):
          # Create DistTensor to save forward results.
          if i == len(self.layers) - 1:
              out_dim = self.n_classes
              name = "h_last"
          else:
              out_dim = self.n_hidden
              name = "h"
          y = dgl.distributed.DistTensor(
              (g.num_nodes(), out_dim),
              th.float32,
              name,
              persistent=True,
          )
          print(
              f"|V|={g.num_nodes()}, inference batch size: {batch_size}"
          )
  
          # `-1` indicates all inbound edges will be inlcuded, namely, full
          # neighbor sampling.
          sampler = dgl.dataloading.NeighborSampler([-1])
          dataloader = dgl.dataloading.DistNodeDataLoader(
              g,
              nodes,
              sampler,
              batch_size=batch_size,
              shuffle=False,
              drop_last=False,
          )
  
          for input_nodes, output_nodes, blocks in tqdm.tqdm(
              dataloader
          ):
              block = blocks[0].to(device)
              h = x[input_nodes].to(device)
              h_dst = h[: block.number_of_dst_nodes()]
              h = layer(block, (h, h_dst))
              if i != len(self.layers) - 1:
                  h = self.activation(h)
                  h = self.dropout(h)
              # Copy back to CPU as DistTensor requires data reside on CPU.
              y[output_nodes] = h.cpu()
  
          x = y
          # Synchronize trainers.
          g.barrier()
      return x
  
file_path: dgl/examples/distributed/graphsage/node_classification.py
imports: import argparse
  import socket
  import time
  import dgl
  import dgl.nn.pytorch
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import tqdm
label_desc: Use image node_id 3 for calling the DistSAGE obj's underlying member method code with example usage: obj.inference(g, x, batch_size, device) and returns: x