class_docstr: :class:`RepeatableSampler` is used to sample negative items for each input user. The difference from
  :class:`Sampler` is it can only sampling the items that have not appeared at all phases.
  
  Args:
      phases (str or list of str): All the phases of input.
      dataset (Dataset): The union of all datasets for each phase.
      distribution (str, optional): Distribution of the negative items. Defaults to 'uniform'.
  
  Attributes:
      phase (str): the phase of sampler. It will not be set until :meth:`set_phase` is called.
class_docstr_tok: [":","class",":","`","RepeatableSampler","`","is","used","to","sample","negative","items","for","each","input","user",".","The","difference","from",":","class",":","`","Sampler","`","is","it","can","only","sampling","the","items","that","have","not","appeared","at","all","phases",".","Args",":","phases","(","str","or","list","of","str",")",":","All","the","phases","of","input",".","dataset","(","Dataset",")",":","The","union","of","all","datasets","for","each","phase",".","distribution","(","str",",","optional",")",":","Distribution","of","the","negative","items",".","Defaults","to","'uniform","'",".","Attributes",":","phase","(","str",")",":","the","phase","of","sampler",".","It","will","not","be","set","until",":","meth",":","`","set_phase","`","is","called","."]
docstr: Sampling by user_ids.
  
  Args:
      user_ids (numpy.ndarray or list): Input user_ids.
      item_ids (numpy.ndarray or list): Input item_ids.
      num (int): Number of sampled item_ids for each user_id.
  
  Returns:
      torch.tensor: Sampled item_ids.
      item_ids[0], item_ids[len(user_ids)], item_ids[len(user_ids) * 2], ..., item_id[len(user_ids) * (num - 1)]
      is sampled for user_ids[0];
      item_ids[1], item_ids[len(user_ids) + 1], item_ids[len(user_ids) * 2 + 1], ...,
      item_id[len(user_ids) * (num - 1) + 1] is sampled for user_ids[1]; ...; and so on.
docstr_tok: ["Sampling","by","user_ids",".","Args",":","user_ids","(","numpy.ndarray","or","list",")",":","Input","user_ids",".","item_ids","(","numpy.ndarray","or","list",")",":","Input","item_ids",".","num","(","int",")",":","Number","of","sampled","item_ids","for","each","user_id",".","Returns",":","torch.tensor",":","Sampled","item_ids",".","item_ids","[","0","]",",","item_ids","[","len","(","user_ids",")","]",",","item_ids","[","len","(","user_ids",")","*","2","]",",","...",",","item_id","[","len","(","user_ids",")","*","(","num","-","1",")","]","is","sampled","for","user_ids","[","0","]",";","item_ids","[","1","]",",","item_ids","[","len","(","user_ids",")","+","1","]",",","item_ids","[","len","(","user_ids",")","*","2","+","1","]",",","...",",","item_id","[","len","(","user_ids",")","*","(","num","-","1",")","+","1","]","is","sampled","for","user_ids","[","1","]",";","...",";","and","so","on","."]
code: def sample_by_user_ids(self, user_ids, item_ids, num):
      """Sampling by user_ids.
  
      Args:
          user_ids (numpy.ndarray or list): Input user_ids.
          item_ids (numpy.ndarray or list): Input item_ids.
          num (int): Number of sampled item_ids for each user_id.
  
      Returns:
          torch.tensor: Sampled item_ids.
          item_ids[0], item_ids[len(user_ids)], item_ids[len(user_ids) * 2], ..., item_id[len(user_ids) * (num - 1)]
          is sampled for user_ids[0];
          item_ids[1], item_ids[len(user_ids) + 1], item_ids[len(user_ids) * 2 + 1], ...,
          item_id[len(user_ids) * (num - 1) + 1] is sampled for user_ids[1]; ...; and so on.
      """
      try:
          self.used_ids = np.array([{i} for i in item_ids])
          return self.sample_by_key_ids(np.arange(len(user_ids)), num)
      except IndexError:
          for user_id in user_ids:
              if user_id < 0 or user_id >= self.user_num:
                  raise ValueError(f"user_id [{user_id}] not exist.")
  
imports: import copy
  import numpy
  from numpy.random import sample
  import torch
  from collections import Counter
label_desc: Use image node_id 5 for calling the RepeatableSampler obj's underlying member method code with example usage: obj.sample_by_user_ids(user_ids, item_ids, num) and returns: self