code: def score(
      df,
      x,
      y,
      task=NOT_SUPPORTED_ANYMORE,
      sample=5_000,
      cross_validation=4,
      random_seed=123,
      invalid_score=0,
      catch_errors=True,
  ):
      """
      Calculate the Predictive Power Score (PPS) for "x predicts y".
  
      The score always ranges from 0 to 1 and is data-type agnostic.
  
      A score of 0 means that the column x cannot predict the column y better than a naive baseline model.
      A score of 1 means that the column x can perfectly predict the column y given the model.
      A score between 0 and 1 states the ratio of how much potential predictive power the model achieved compared to the
      baseline model.
  
      Parameters
      ----------
      df : pandas.DataFrame
          Dataframe that contains the columns x and y
      x : str
          Name of the column x which acts as the feature
      y : str
          Name of the column y which acts as the target
      sample : int or `None`
          Number of rows for sampling. The sampling decreases the calculation time of the PPS.
          If `None` there will be no sampling.
      cross_validation : int
          Number of iterations during cross-validation. This has the following implications:
          For example, if the number is 4, then it is possible to detect patterns when there are at least 4 times the same
           observation. If the limit is increased, the required minimum observations also increase. This is important,
           because this is the limit when sklearn will throw an error and the PPS cannot be calculated
      random_seed : int or `None`
          Random seed for the parts of the calculation that require random numbers, e.g. shuffling or sampling.
          If the value is set, the results will be reproducible. If the value is `None` a new random number is drawn at
          the start of each calculation.
      invalid_score : any
          The score that is returned when a calculation is invalid, e.g. because the data type was not supported.
      catch_errors : bool
          If `True` all errors will be catched and reported as `unknown_error` which ensures convenience. If `False`
          errors will be raised. This is helpful for inspecting and debugging errors.
  
      Returns
      -------
      Dict
          A dict that contains multiple fields about the resulting PPS.
          The dict enables introspection into the calculations that have been performed under the hood
      """
      if not isinstance(df, pd.DataFrame):
          raise TypeError(
              f"The 'df' argument should be a pandas.DataFrame but you passed a {type(df)}\nPlease convert your input to "
              f"a pandas.DataFrame"
          )
      if not _is_column_in_df(x, df):
          raise ValueError(
              f"The 'x' argument should be the name of a dataframe column but the variable that you passed is not a "
              f"column in the given dataframe.\nPlease review the column name or your dataframe"
          )
      if len(df[[x]].columns) >= 2:
          raise AssertionError(
              f"The dataframe has {len(df[[x]].columns)} columns with the same column name {x}\nPlease adjust the "
              f"dataframe and make sure that only 1 column has the name {x}"
          )
      if not _is_column_in_df(y, df):
          raise ValueError(
              f"The 'y' argument should be the name of a dataframe column but the variable that you passed is not a "
              f"column in the given dataframe.\nPlease review the column name or your dataframe"
          )
      if len(df[[y]].columns) >= 2:
          raise AssertionError(
              f"The dataframe has {len(df[[y]].columns)} columns with the same column name {y}\nPlease adjust the "
              f"dataframe and make sure that only 1 column has the name {y}"
          )
      if task is not NOT_SUPPORTED_ANYMORE:
          raise AttributeError(
              "The attribute 'task' is no longer supported because it led to confusion and inconsistencies.\nThe task of the model is now determined based on the data types of the columns. If you want to change the task please adjust the data type of the column.\nFor more details, please refer to the README"
          )
  
      if random_seed is None:
          from random import random
  
          random_seed = int(random() * 1000)
  
      try:
          return _score(
              df,
              x,
              y,
              task,
              sample,
              cross_validation,
              random_seed,
              invalid_score,
              catch_errors,
          )
      except Exception as exception:
          if catch_errors:
              case_type = "unknown_error"
              task = _get_task(case_type, invalid_score)
              return {
                  "x": x,
                  "y": y,
                  "ppscore": task["ppscore"],
                  "case": case_type,
                  "is_valid_score": task["is_valid_score"],
                  "metric": task["metric_name"],
                  "baseline_score": task["baseline_score"],
                  "model_score": task[
                      "model_score"
                  ],  # sklearn returns negative mae
                  "model": task["model"],
              }
          else:
              raise exception
  
imports: import warnings
  import numpy
  import pandas
  from pandas.api.types import is_bool_dtype, is_categorical_dtype, is_datetime64_any_dtype, is_numeric_dtype, is_object_dtype, is_string_dtype, is_timedelta64_dtype
  from sklearn import preprocessing, tree
  from sklearn.metrics import f1_score, mean_absolute_error
  from sklearn.model_selection import cross_val_score
  from deepchecks.utils.typing import Hashable
label_desc: Use image node_id 12 for calling a global function with example usage: score(df, x, y, task, sample, cross_validation, random_seed, invalid_score, catch_errors) and returns: _score, dict