code: def run(experiment_name, train, test, validation, random_state):
      results = Results("{}_results.txt".format(experiment_name))
      compression_ratios = (np.arange(1, 10) / 10).tolist()
  
      best_result = results.best()
  
      if best_result is not None:
          print("Best result: {}".format(results.best()))
  
      # Find a good baseline
      for hyperparameters in sample_hyperparameters(
          random_state, NUM_SAMPLES
      ):
          if "factorization" in experiment_name:
              # We want bigger batches for factorization models
              hyperparameters["batch_size"] = (
                  hyperparameters["batch_size"] * 4
              )
  
          hyperparameters["compression_ratio"] = 1.0
  
          if hyperparameters in results:
              print("Done, skipping...")
              continue
  
          if "factorization" in experiment_name:
              model = build_factorization_model(
                  hyperparameters, train, random_state
              )
          else:
              model = build_sequence_model(
                  hyperparameters, train, random_state
              )
  
          print("Fitting {}".format(hyperparameters))
          (test_mrr, val_mrr, elapsed) = evaluate_model(
              model, train, test, validation
          )
  
          print(
              "Test MRR {} val MRR {} elapsed {}".format(
                  test_mrr.mean(), val_mrr.mean(), elapsed
              )
          )
  
          results.save(
              hyperparameters, test_mrr.mean(), val_mrr.mean(), elapsed
          )
  
      best_baseline = results.best_baseline()
      print("Best baseline: {}".format(best_baseline))
  
      # Compute compression results
      for compression_ratio in compression_ratios:
          hyperparameters = best_baseline
          hyperparameters["compression_ratio"] = compression_ratio
  
          if hyperparameters in results:
              print("Compression computed")
              continue
  
          if "factorization" in experiment_name:
              model = build_factorization_model(
                  hyperparameters, train, random_state
              )
          else:
              model = build_sequence_model(
                  hyperparameters, train, random_state
              )
  
          print("Evaluating {}".format(hyperparameters))
  
          (test_mrr, val_mrr, elapsed) = evaluate_model(
              model, train, test, validation
          )
          print(
              "Test MRR {} val MRR {} elapsed {}".format(
                  test_mrr.mean(), val_mrr.mean(), elapsed
              )
          )
  
          results.save(
              hyperparameters, test_mrr.mean(), val_mrr.mean(), elapsed
          )
  
      return results
  
imports: import argparse
  import hashlib
  import json
  import os
  import shutil
  import time
  import numpy
  from sklearn.model_selection import ParameterSampler
  from spotlight.datasets.movielens import get_movielens_dataset
  from spotlight.datasets.amazon import get_amazon_dataset
  from spotlight.cross_validation import random_train_test_split, user_based_train_test_split
  from spotlight.sequence.implicit import ImplicitSequenceModel
  from spotlight.factorization.implicit import ImplicitFactorizationModel
  from spotlight.sequence.representations import LSTMNet
  from spotlight.factorization.representations import BilinearNet
  from spotlight.layers import BloomEmbedding, ScaledEmbedding
  from spotlight.evaluation import mrr_score, sequence_mrr_score
  from spotlight.torch_utils import set_seed
label_desc: Use image node_id 5 for calling a global function with example usage: run(experiment_name, train, test, validation, random_state) and returns: results