code: def _get_sampled_data(instance_file, sample_rate):
      logger.info("getting sampled data...")
      global item2cate
      output_file = instance_file + "_" + str(sample_rate)
      columns = ["label", "user_id", "item_id", "timestamp", "cate_id"]
      ns_df = pd.read_csv(instance_file, sep="\t", names=columns)
      items_num = ns_df["item_id"].nunique()
      items_with_popular = list(ns_df["item_id"])
      items_sample, count = set(), 0
      while count < int(items_num * sample_rate):
          random_item = random.choice(items_with_popular)
          if random_item not in items_sample:
              items_sample.add(random_item)
              count += 1
      ns_df_sample = ns_df[ns_df["item_id"].isin(items_sample)]
      ns_df_sample.to_csv(
          output_file, sep="\t", index=None, header=None
      )
      return output_file
  
imports: import os
  import shutil
  import pandas
  import gzip
  import random
  import logging
  import _pickle
  from recommenders.utils.constants import SEED
  from recommenders.datasets.download_utils import maybe_download
label_desc: Use image node_id 8 for calling a global function with example usage: _get_sampled_data(instance_file, sample_rate) and returns: output_file