docstr: a subprocess for fast_train_mp
docstr_tok: ["a","subprocess","for","fast_train_mp"]
code: def fast_train_sp(self, rank, gpu_id):
      """a subprocess for fast_train_mp"""
      if self.args.mix:
          self.emb_model.set_device(gpu_id)
  
      torch.set_num_threads(self.args.num_threads)
      if self.args.async_update:
          self.emb_model.create_async_update()
  
      sampler = self.dataset.create_sampler(rank)
  
      dataloader = DataLoader(
          dataset=sampler.seeds,
          batch_size=self.args.batch_size,
          collate_fn=sampler.sample,
          shuffle=False,
          drop_last=False,
          num_workers=self.args.num_sampler_threads,
      )
      num_batches = len(dataloader)
      print(
          "num batchs: %d in process [%d] GPU [%d]"
          % (num_batches, rank, gpu_id)
      )
      # number of positive node pairs in a sequence
      num_pos = int(
          2 * self.args.walk_length * self.args.window_size
          - self.args.window_size * (self.args.window_size + 1)
      )
  
      start = time.time()
      with torch.no_grad():
          for i, walks in enumerate(dataloader):
              if self.args.fast_neg:
                  self.emb_model.fast_learn(walks)
              else:
                  # do negative sampling
                  bs = len(walks)
                  neg_nodes = torch.LongTensor(
                      np.random.choice(
                          self.dataset.neg_table,
                          bs * num_pos * self.args.negative,
                          replace=True,
                      )
                  )
                  self.emb_model.fast_learn(walks, neg_nodes=neg_nodes)
  
              if i > 0 and i % self.args.print_interval == 0:
                  if self.args.print_loss:
                      print(
                          "GPU-[%d] batch %d time: %.2fs loss: %.4f"
                          % (
                              gpu_id,
                              i,
                              time.time() - start,
                              -sum(self.emb_model.loss)
                              / self.args.print_interval,
                          )
                      )
                      self.emb_model.loss = []
                  else:
                      print(
                          "GPU-[%d] batch %d time: %.2fs"
                          % (gpu_id, i, time.time() - start)
                      )
                  start = time.time()
  
          if self.args.async_update:
              self.emb_model.finish_async_update()
  
file_path: dgl/examples/pytorch/ogb/deepwalk/deepwalk.py
imports: import argparse
  import os
  import random
  import time
  import dgl
  import numpy
  import torch
  import torch.multiprocessing
  from model import SkipGramModel
  from reading_data import DeepwalkDataset
  from torch.utils.data import DataLoader
  from utils import shuffle_walks, sum_up_params
label_desc: Use image node_id 5 for calling the DeepwalkTrainer obj's underlying member method code with example usage: obj.fast_train_sp(rank, gpu_id) without return types