code: def capper(
      df: pd.DataFrame,
      columns_to_cap: List[str],
      precomputed_caps: Dict[str, float] = None,
  ) -> LearnerReturnType:
      """
      Learns the maximum value for each of the `columns_to_cap`
      and used that as the cap for those columns. If precomputed caps
      are passed, the function uses that as the cap value instead of
      computing the maximum.
  
      Parameters
      ----------
      df : pandas.DataFrame
          A Pandas' DataFrame that must contain `columns_to_cap` columns.
  
      columns_to_cap : list of str
          A list os column names that should be caped.
  
      precomputed_caps : dict
          A dictionary on the format {"column_name" : cap_value}.
          That maps column names to pre computed cap values
      """
  
      if not precomputed_caps:
          precomputed_caps = {}
  
      caps = {
          col: precomputed_caps.get(col, df[col].max())
          for col in columns_to_cap
      }
  
      def p(new_data_set: pd.DataFrame) -> pd.DataFrame:
          capped_cols = {
              col: new_data_set[col].clip(upper=caps[col])
              for col in caps.keys()
          }
          return new_data_set.assign(**capped_cols)
  
      p.__doc__ = learner_pred_fn_docstring("capper")
  
      log = {
          "capper": {
              "caps": caps,
              "transformed_column": columns_to_cap,
              "precomputed_caps": precomputed_caps,
          }
      }
  
      return p, p(df), log
  
imports: from typing import Any, Callable, Dict, List, Union, Optional
  import numpy
  import pandas
  from numpy import nan
  from sklearn.preprocessing import StandardScaler
  from statsmodels.distributions import empirical_distribution
  from toolz import curry, merge, compose, mapcat
  from fklearn.common_docstrings import learner_return_docstring, learner_pred_fn_docstring
  from fklearn.training.utils import log_learner_time
  from fklearn.types import LearnerReturnType, LearnerLogType
  from fklearn.preprocessing.schema import column_duplicatable
label_desc: Use image node_id 2 for calling a global function with example usage: capper(df, columns_to_cap, precomputed_caps) and returns: p,  p,  log, new_data_set