code: def _per_pos_stratified_pointwise_generator(datastore, pos_ratio):
      num_negative_per_positive = int((1 - pos_ratio) / pos_ratio)
  
      while True:
          entry = datastore.next_random_record()
          user_id = entry["user_id"]
          p_item_id = entry["item_id"]
          yield {"user_id": user_id, "item_id": p_item_id, "label": 1.0}
  
          count = 0
          for n_item_id in random.sample(
              range(datastore.total_items()),
              k=num_negative_per_positive + 1,
          ):
              if n_item_id == p_item_id:
                  continue
              yield {
                  "user_id": user_id,
                  "item_id": n_item_id,
                  "label": 0.0,
              }
              count += 1
              if count >= num_negative_per_positive:
                  break
  
file_path: openrec/openrec/tf2/data/dataset.py
imports: from openrec.tf2.data import _ParallelDataset
  from openrec.tf2.data import _DataStore
  import tensorflow
  import numpy
  import random
label_desc: Use image node_id 3 for calling a global function with example usage: _per_pos_stratified_pointwise_generator(datastore, pos_ratio) without return types