code: def min_rating_filter_spark(
      data,
      min_rating=1,
      filter_by="user",
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
  ):
      """Filter rating DataFrame for each user with minimum rating.
  
      Filter rating data frame with minimum number of ratings for user/item is usually useful to
      generate a new data frame with warm user/item. The warmth is defined by min_rating argument. For
      example, a user is called warm if he has rated at least 4 items.
  
      Args:
          data (pyspark.sql.DataFrame): DataFrame of user-item tuples. Columns of user and item
              should be present in the DataFrame while other columns like rating,
              timestamp, etc. can be optional.
          min_rating (int): minimum number of ratings for user or item.
          filter_by (str): either "user" or "item", depending on which of the two is to
              filter with min_rating.
          col_user (str): column name of user ID.
          col_item (str): column name of item ID.
  
      Returns:
          pyspark.sql.DataFrame: DataFrame with at least columns of user and item that has been filtered by the given specifications.
      """
  
      split_by_column = _get_column_name(filter_by, col_user, col_item)
  
      if min_rating < 1:
          raise ValueError(
              "min_rating should be integer and larger than or equal to 1."
          )
  
      if min_rating > 1:
          window = Window.partitionBy(split_by_column)
          data = (
              data.withColumn(
                  "_count", F.count(split_by_column).over(window)
              )
              .where(F.col("_count") >= min_rating)
              .drop("_count")
          )
  
      return data
  
file_path: recommenders/recommenders/datasets/split_utils.py
imports: import numpy
  import math
  import logging
  from recommenders.utils.constants import DEFAULT_ITEM_COL, DEFAULT_USER_COL
label_desc: Use image node_id 3 for calling a global function with example usage: min_rating_filter_spark(data, min_rating, filter_by, col_user, col_item) and returns: data