code: def _get_item_feature_similarity(
      item_feature_df,
      col_item_features=DEFAULT_ITEM_FEATURES_COL,
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
      col_sim=DEFAULT_SIMILARITY_COL,
  ):
      """Cosine similarity metric based on item feature vectors
  
      The item indexes in the result are such that i1 <= i2.
      """
      df1 = item_feature_df[[col_item, col_item_features]]
      df1.columns = ["i1", "f1"]
      df1["key"] = 0
      df2 = item_feature_df[[col_item, col_item_features]]
      df2.columns = ["i2", "f2"]
      df2["key"] = 0
  
      df = pd.merge(df1, df2, on="key", how="outer").drop("key", axis=1)
      df_item_feature_pair = df[(df["i1"] <= df["i2"])].reset_index(
          drop=True
      )
  
      df_item_feature_pair[col_sim] = df_item_feature_pair.apply(
          lambda x: float(x.f1.dot(x.f2))
          / float(np.linalg.norm(x.f1, 2) * np.linalg.norm(x.f2, 2)),
          axis=1,
      )
  
      df_cosine_similarity = df_item_feature_pair[
          ["i1", "i2", col_sim]
      ].sort_values(["i1", "i2"])
  
      return df_cosine_similarity
  
imports: import numpy
  import pandas
  from functools import wraps
  from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score, explained_variance_score, roc_auc_score, log_loss
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_PREDICTION_COL, DEFAULT_RELEVANCE_COL, DEFAULT_SIMILARITY_COL, DEFAULT_ITEM_FEATURES_COL, DEFAULT_ITEM_SIM_MEASURE, DEFAULT_K, DEFAULT_THRESHOLD
  from recommenders.datasets.pandas_df_utils import has_columns, has_same_base_dtype, lru_cache_df
label_desc: Use image node_id 22 for calling a global function with example usage: _get_item_feature_similarity(item_feature_df, col_item_features, col_user, col_item, col_sim) and returns: df_cosine_similarity