class_docstr: NegativeSampler class for NCF. Samples a subset of negative items from a given population of items.
class_docstr_tok: ["NegativeSampler","class","for","NCF",".","Samples","a","subset","of","negative","items","from","a","given","population","of","items","."]
code: def _check_sample_size(self):
      # if sampling without replacement, check sample population is sufficient and reduce
      # n_samples if not.
      n_neg_var = "n_neg" if self.training else "n_neg_test"
      dataset_name = "training" if self.training else "test"
  
      k = min(self.n_samples, self.population_size)
      if k < self.n_samples and self.print_warnings:
          warning_string = (
              "The population of negative items to sample from is too small for user {}. "
              "Samples needed = {}, negative items = {}. "
              "Reducing samples to {} for this user."
              "If an equal number of negative samples for each user is required in the {} set, sample with replacement or reduce {}. "
              "This warning can be turned off by setting print_warnings=False".format(
                  self.user,
                  self.n_samples,
                  self.population_size,
                  self.population_size,
                  dataset_name,
                  n_neg_var,
              )
          )
          logging.warning(warning_string)
      self.n_samples = k
  
imports: import os
  from collections import OrderedDict
  import random
  import numpy
  import pandas
  import csv
  import logging
  from tqdm import tqdm
  from recommenders.utils.constants import DEFAULT_ITEM_COL, DEFAULT_USER_COL, DEFAULT_RATING_COL
label_desc: Use image node_id 6 for calling the NegativeSampler obj's underlying member method code with example usage: obj._check_sample_size() without return types