code: def spark_diversity_data(diversity_data, spark):
      train_df, reco_df, item_feature_df = diversity_data
  
      train_df = spark.createDataFrame(train_df)
      reco_df = spark.createDataFrame(reco_df)
      item_feature_df["features"] = item_feature_df["features"].apply(
          lambda x: x.tolist()
      )
      field = [
          StructField("ItemId", IntegerType(), True),
          StructField("features", ArrayType(FloatType()), True),
      ]
      item_feature_df = spark.createDataFrame(
          item_feature_df, schema=StructType(field)
      )
      # Array[Float] to VectorUDT
      item_feature_df = item_feature_df.withColumn(
          "features", array_to_vector(item_feature_df["features"])
      )
  
      return train_df, reco_df, item_feature_df
  
imports: import pytest
  import numpy
  import pandas
  from pandas.util.testing import assert_frame_equal
  from recommenders.evaluation.python_evaluation import precision_at_k, recall_at_k, ndcg_at_k, map_at_k, map
label_desc: Use image node_id 2 for calling a global function with example usage: spark_diversity_data(diversity_data, spark) and returns: train_df,  reco_df,  item_feature_df