docstr: Conduct layer-wise inference to get all the node embeddings.
docstr_tok: ["Conduct","layer-wise","inference","to","get","all","the","node","embeddings","."]
code: def inference(self, g, device, batch_size):
      """Conduct layer-wise inference to get all the node embeddings."""
      all_node_ids = torch.arange(0, g.num_nodes()).to(device)
      feat = g.get_node_storage(key="feat", ntype="_N").fetch(
          all_node_ids, device=device
      )
  
      sampler = MultiLayerFullNeighborSampler(
          1, prefetch_node_feats=["feat"]
      )
      dataloader = DataLoader(
          g,
          torch.arange(g.num_nodes()).to(g.device),
          sampler,
          device=device,
          batch_size=batch_size,
          shuffle=False,
          drop_last=False,
          num_workers=0,
      )
      buffer_device = torch.device("cpu")
      pin_memory = buffer_device != device
  
      for l_id, layer in enumerate(self.layers):
          y = torch.empty(
              g.num_nodes(),
              self.hid_size
              if l_id != len(self.layers) - 1
              else self.out_size,
              device=buffer_device,
              pin_memory=pin_memory,
          )
          feat = feat.to(device)
          for input_nodes, output_nodes, blocks in tqdm.tqdm(
              dataloader
          ):
              x = feat[input_nodes]
              h = layer(blocks[0], x)  # len(blocks) = 1
              if l_id != len(self.layers) - 1:
                  h = F.relu(h)
                  h = self.dropout(h)
              # by design, our output nodes are contiguous
              y[output_nodes[0] : output_nodes[-1] + 1] = h.to(
                  buffer_device
              )
          feat = y
      return y
  
imports: import warnings
  import time
  import cugraph_dgl
  import torch
  import torch.nn
  import torch.nn.functional
  import torchmetrics.functional
  import dgl
  import dgl.nn
  from dgl.data import AsNodePredDataset
  from dgl.dataloading import DataLoader, NeighborSampler, MultiLayerFullNeighborSampler
  from ogb.nodeproppred import DglNodePropPredDataset
  import tqdm
  import argparse
label_desc: Use image node_id 3 for calling the SAGE obj's underlying member method code with example usage: obj.inference(g, device, batch_size) and returns: y