class_docstr: Dataset for validation or testing
  
  Parameters
  ----------
  dataset : KGDataset
      Original dataset.
  args :
      Global configs.
class_docstr_tok: ["Dataset","for","validation","or","testing","Parameters","--","--","--","--","--","dataset",":","KGDataset","Original","dataset",".","args",":","Global","configs","."]
docstr: Create sampler for validation or testing
  
  Parameters
  ----------
  eval_type : str
      Sampling type, 'valid' for validation and 'test' for testing
  batch_size : int
      Batch size of each mini batch.
  neg_sample_size : int
      How many negative edges sampled for each node.
  neg_chunk_size : int
      How many edges in one chunk. We split one batch into chunks.
  filter_false_neg : bool
      If True, exlucde true positive edges in sampled negative edges
      If False, return all sampled negative edges even there are positive edges
  mode : str
      Sampling mode.
  number_workers: int
      Number of workers used in parallel for this sampler
  rank : int
      Which partition to sample.
  ranks : int
      Total number of partitions.
  
  Returns
  -------
  dgl.contrib.sampling.EdgeSampler
      Edge sampler
docstr_tok: ["Create","sampler","for","validation","or","testing","Parameters","--","--","--","--","--","eval_type",":","str","Sampling","type",",","'valid","'","for","validation","and","'test","'","for","testing","batch_size",":","int","Batch","size","of","each","mini","batch",".","neg_sample_size",":","int","How","many","negative","edges","sampled","for","each","node",".","neg_chunk_size",":","int","How","many","edges","in","one","chunk",".","We","split","one","batch","into","chunks",".","filter_false_neg",":","bool","If","True",",","exlucde","true","positive","edges","in","sampled","negative","edges","If","False",",","return","all","sampled","negative","edges","even","there","are","positive","edges","mode",":","str","Sampling","mode",".","number_workers",":","int","Number","of","workers","used","in","parallel","for","this","sampler","rank",":","int","Which","partition","to","sample",".","ranks",":","int","Total","number","of","partitions",".","Returns","--","--","--","-","dgl.contrib.sampling.EdgeSampler","Edge","sampler"]
code: def create_sampler(
      self,
      eval_type,
      batch_size,
      neg_sample_size,
      neg_chunk_size,
      filter_false_neg,
      mode="head",
      num_workers=32,
      rank=0,
      ranks=1,
  ):
      """Create sampler for validation or testing
  
      Parameters
      ----------
      eval_type : str
          Sampling type, 'valid' for validation and 'test' for testing
      batch_size : int
          Batch size of each mini batch.
      neg_sample_size : int
          How many negative edges sampled for each node.
      neg_chunk_size : int
          How many edges in one chunk. We split one batch into chunks.
      filter_false_neg : bool
          If True, exlucde true positive edges in sampled negative edges
          If False, return all sampled negative edges even there are positive edges
      mode : str
          Sampling mode.
      number_workers: int
          Number of workers used in parallel for this sampler
      rank : int
          Which partition to sample.
      ranks : int
          Total number of partitions.
  
      Returns
      -------
      dgl.contrib.sampling.EdgeSampler
          Edge sampler
      """
      edges = self.get_dicts(eval_type)
      new_edges = {}
      assert "tail" in mode
      # if 'head' in mode:
      #     beg = edges['t,r->h']['tr'].shape[0] * rank // ranks
      #     end = min(edges['t,r->h']['tr'].shape[0] * (rank + 1) // ranks, edges['t,r->h']['tr'].shape[0])
      #     new_edges['t,r->h'] = {'tr': edges['t,r->h']['tr'][beg:end],
      #                             'h_candidate': edges['t,r->h']['h_candidate'][beg:end],
      #                         #    'h_correct_index': edges['t,r->h']['h_correct_index'][beg:end]
      #                             }
      #     if 'h_correct_index' in edges['t,r->h']:
      #         new_edges['t,r->h']['h_correct_index'] = edges['t,r->h']['h_correct_index'][beg:end]
      #     else:
      #         new_edges['t,r->h']['h_correct_index'] = np.zeros(end-beg, dtype=np.short)
  
      if "tail" in mode:
          beg = edges["h,r->t"]["hr"].shape[0] * rank // ranks
          end = min(
              edges["h,r->t"]["hr"].shape[0] * (rank + 1) // ranks,
              edges["h,r->t"]["hr"].shape[0],
          )
          new_edges["h,r->t"] = {
              "hr": edges["h,r->t"]["hr"][beg:end],
              "t_candidate": edges["h,r->t"]["t_candidate"][beg:end],
              #    't_correct_index': edges['h,r->t']['t_correct_index'][beg:end]
          }
          if "t_correct_index" in edges["h,r->t"]:
              new_edges["h,r->t"]["t_correct_index"] = edges["h,r->t"][
                  "t_correct_index"
              ][beg:end]
          else:
              new_edges["h,r->t"]["t_correct_index"] = np.zeros(
                  end - beg, dtype=np.short
              )
      else:
          assert False, mode
      print(beg, end)
      return WikiEvalSampler(new_edges, batch_size, mode)
  
imports: import math
  import numpy
  import scipy
  import dgl.backend
  import dgl
  import os
  import sys
  import pickle
  import time
  from dgl.base import NID, EID
  import pdb
label_desc: Use image node_id 4 for calling the EvalDataset obj's underlying member method code with example usage: obj.create_sampler(eval_type, batch_size, neg_sample_size, neg_chunk_size, filter_false_neg, mode, num_workers, rank, ranks) and returns: WikiEvalSampler