code: def distributional_coverage(
      train_df,
      reco_df,
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
  ):
      """Calculate distributional coverage for recommendations across all users.
      The metric definition is based on formula (21) in the following reference:
  
      :Citation:
  
          G. Shani and A. Gunawardana, Evaluating Recommendation Systems,
          Recommender Systems Handbook pp. 257-297, 2010.
  
      Args:
          train_df (pandas.DataFrame): Data set with historical data for users and items they
                  have interacted with; contains col_user, col_item. Assumed to not contain any duplicate rows.
                  Interaction here follows the *item choice model* from Castells et al.
          reco_df (pandas.DataFrame): Recommender's prediction output, containing col_user, col_item,
                  col_relevance (optional). Assumed to not contain any duplicate user-item pairs.
          col_user (str): User id column name.
          col_item (str): Item id column name.
  
      Returns:
          float: distributional coverage
      """
      # In reco_df, how  many times each col_item is being recommended
      df_itemcnt_reco = pd.DataFrame(
          {"count": reco_df.groupby([col_item]).size()}
      ).reset_index()
  
      # the number of total recommendations
      count_row_reco = reco_df.shape[0]
  
      df_entropy = df_itemcnt_reco
      df_entropy["p(i)"] = df_entropy["count"] / count_row_reco
      df_entropy["entropy(i)"] = df_entropy["p(i)"] * np.log2(
          df_entropy["p(i)"]
      )
  
      d_coverage = -df_entropy.agg({"entropy(i)": "sum"})[0]
  
      return d_coverage
  
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 32 for calling a global function with example usage: distributional_coverage(train_df, reco_df, col_user, col_item) and returns: d_coverage