code: def filter_by_freq(
      df_to_filter, df_for_stats, column, min_freq=None, max_freq=None
  ):
      # Frequencies of each value in the column.
      freq = df_for_stats[column].value_counts()
  
      if min_freq is not None:
          cond = freq >= min_freq
      elif max_freq is not None:
          cond = freq <= max_freq
      elif min_freq is not None and max_freq is not None:
          cond = min_freq >= freq <= max_freq
  
      # Select frequent values. Value is in the index.
      frequent_values = (
          freq[cond].reset_index()["index"].to_frame(column)
      )
      # Return only rows with value frequency above threshold.
      return df_to_filter.merge(frequent_values, on=column, how="inner")
  
imports: import gc
  import logging
  import os
  import shutil
  from functools import reduce
  from typing import Optional
  import nvtabular
  from merlin.core.dispatch import HAS_GPU
  from merlin.schema import Tags
  from nvtabular import ops
  from .args_parsing import parse_arguments
label_desc: Use image node_id 1 for calling a global function with example usage: filter_by_freq(df_to_filter, df_for_stats, column, min_freq, max_freq) and returns: df_to_filter