docstr: Inference with the GAT model on full neighbors (i.e. without neighbor sampling).
  g : the entire graph.
  x : the input of entire node set.
  The inference code is written in a fashion that it could handle any number of nodes and
  layers.
docstr_tok: ["Inference","with","the","GAT","model","on","full","neighbors","(","i.e",".","without","neighbor","sampling",")",".","g",":","the","entire","graph",".","x",":","the","input","of","entire","node","set",".","The","inference","code","is","written","in","a","fashion","that","it","could","handle","any","number","of","nodes","and","layers","."]
code: def inference(self, g, x, batch_size, device):
      """
      Inference with the GAT model on full neighbors (i.e. without neighbor sampling).
      g : the entire graph.
      x : the input of entire node set.
      The inference code is written in a fashion that it could handle any number of nodes and
      layers.
      """
      num_heads = self.num_heads
      for l, layer in enumerate(self.layers):
          if l < self.n_layers - 1:
              y = th.zeros(
                  g.num_nodes(),
                  self.n_hidden * num_heads
                  if l != len(self.layers) - 1
                  else self.n_classes,
              )
          else:
              y = th.zeros(
                  g.num_nodes(),
                  self.n_hidden
                  if l != len(self.layers) - 1
                  else self.n_classes,
              )
          sampler = dgl.dataloading.MultiLayerFullNeighborSampler(1)
          dataloader = dgl.dataloading.DataLoader(
              g,
              th.arange(g.num_nodes()),
              sampler,
              batch_size=batch_size,
              shuffle=False,
              drop_last=False,
              num_workers=args.num_workers,
          )
  
          with dataloader.enable_cpu_affinity():
              for input_nodes, output_nodes, blocks in tqdm.tqdm(
                  dataloader
              ):
                  block = blocks[0].int().to(device)
                  h = x[input_nodes].to(device)
                  if l < self.n_layers - 1:
                      h = layer(block, h).flatten(1)
                  else:
                      h = layer(block, h)
                      h = h.mean(1)
                      h = h.log_softmax(dim=-1)
  
                  y[output_nodes] = h.cpu()
          x = y
      return y
  
imports: import argparse
  import time
  from functools import partial
  import dgl
  import dgl.nn.pytorch
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.optim
  import tqdm
  from ogb.nodeproppred import DglNodePropPredDataset
  from sampler import ClusterIter, subgraph_collate_fn
  from torch.utils.data import DataLoader
label_desc: Use image node_id 3 for calling the GAT obj's underlying member method code with example usage: obj.inference(g, x, batch_size, device) and returns: y