code: def python_dataset(test_specs):
      """Get Python labels"""
  
      def random_date_generator(start_date, range_in_days):
          """Helper function to generate random timestamps.
  
          Reference: https://stackoverflow.com/questions/41006182/generate-random-dates-within-a-range-in-numpy
          """
  
          days_to_add = np.arange(0, range_in_days)
          random_dates = []
  
          for i in range(range_in_days):
              random_date = np.datetime64(
                  start_date
              ) + np.random.choice(days_to_add)
              random_dates.append(random_date)
  
          return random_dates
  
      # fix the the random seed
      np.random.seed(test_specs["seed"])
  
      # generates the user/item affinity matrix. Ratings are from 1 to 5, with 0s denoting unrated items
      X = np.random.randint(
          low=0,
          high=6,
          size=(
              test_specs["number_of_users"],
              test_specs["number_of_items"],
          ),
      )
  
      # In the main code, input data are passed as pandas dataframe. Below we generate such df from the above matrix
      userids = []
  
      for i in range(1, test_specs["number_of_users"] + 1):
          userids.extend([i] * test_specs["number_of_items"])
  
      itemids = [
          i for i in range(1, test_specs["number_of_items"] + 1)
      ] * test_specs["number_of_users"]
      ratings = np.reshape(X, -1)
  
      # create dataframe
      results = pd.DataFrame.from_dict(
          {
              DEFAULT_USER_COL: userids,
              DEFAULT_ITEM_COL: itemids,
              DEFAULT_RATING_COL: ratings,
              DEFAULT_TIMESTAMP_COL: random_date_generator(
                  "2018-01-01",
                  test_specs["number_of_users"]
                  * test_specs["number_of_items"],
              ),
          }
      )
  
      # here we eliminate the missing ratings to obtain a standard form of the df as that of real data.
      results = results[results.rating != 0]
  
      return results
  
file_path: recommenders/tests/unit/recommenders/datasets/test_sparse.py
imports: import pandas
  import numpy
  import pytest
  from recommenders.datasets.sparse import AffinityMatrix
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_TIMESTAMP_COL
label_desc: Use image node_id 2 for calling a global function with example usage: python_dataset(test_specs) and returns: results, random_dates