docstr: Minibatch inference of final representation over all node types.
  
  ***NOTE***
  For node classification, the model is trained to predict on only one node type's
  label.  Therefore, only that type's final representation is meaningful.
docstr_tok: ["Minibatch","inference","of","final","representation","over","all","node","types",".","*","*","*","NOTE","*","*","*","For","node","classification",",","the","model","is","trained","to","predict","on","only","one","node","type's","label",".","Therefore",",","only","that","type","'s","final","representation","is","meaningful","."]
code: def inference(self, g, batch_size, device, num_workers, x=None):
      """Minibatch inference of final representation over all node types.
  
      ***NOTE***
      For node classification, the model is trained to predict on only one node type's
      label.  Therefore, only that type's final representation is meaningful.
      """
  
      if x is None:
          x = self.embed_layer()
  
      for l, layer in enumerate(self.layers):
          y = {
              k: th.zeros(
                  g.num_nodes(k),
                  self.h_dim
                  if l != len(self.layers) - 1
                  else self.out_dim,
              )
              for k in g.ntypes
          }
  
          sampler = dgl.dataloading.MultiLayerFullNeighborSampler(1)
          dataloader = dgl.dataloading.DataLoader(
              g,
              {k: th.arange(g.num_nodes(k)) for k in g.ntypes},
              sampler,
              batch_size=batch_size,
              shuffle=True,
              drop_last=False,
              num_workers=num_workers,
          )
  
          with dataloader.enable_cpu_affinity():
              for input_nodes, output_nodes, blocks in tqdm.tqdm(
                  dataloader
              ):
                  block = blocks[0].to(device)
  
                  h = {
                      k: x[k][input_nodes[k]].to(device)
                      for k in input_nodes.keys()
                  }
                  h = layer(block, h)
  
                  for k in output_nodes.keys():
                      y[k][output_nodes[k]] = h[k].cpu()
  
          x = y
      return y
  
imports: from collections import defaultdict
  import dgl
  import dgl.function
  import dgl.nn
  import torch
  import torch.nn
  import torch.nn.functional
  import tqdm
label_desc: Use image node_id 3 for calling the EntityClassify obj's underlying member method code with example usage: obj.inference(g, batch_size, device, num_workers, x) and returns: y