def rm_spacy_stopwords(
    df,
    sentence_cols=["sentence1", "sentence2"],
    stop_cols=["sentence1_tokens_rm_stopwords", "sentence2_tokens_rm_stopwords"],
    custom_stopwords=[],
):
    """
    This function tokenizes the sentence pairs using spaCy and remove
    stopwords, defaulting to the spaCy en_core_web_sm model

    Args:
        df (pd.DataFrame): Dataframe with columns sentence_cols to tokenize.
        sentence_cols (list, optional): Column names for the raw sentence
        pairs.
        stop_cols (list, optional): Column names for the tokenized sentences
            without stop words.
        custom_stopwords (list of str, optional): List of custom stopwords to
            register with the spaCy model.

    Returns:
        pd.DataFrame: Dataframe with new columns stop_cols, each containing a
            list of tokens for their respective sentences.
    """
    nlp = spacy.load("en_core_web_sm")
    if len(custom_stopwords) > 0:
        for csw in custom_stopwords:
            nlp.vocab[csw].is_stop = True
    text_df = df[sentence_cols]
    nlp_df = text_df.applymap(lambda x: nlp(x))
    stop_df = nlp_df.applymap(lambda doc: [token.text for token in doc if not token.is_stop])
    stop_df.columns = stop_cols
    return pd.concat([df, stop_df], axis=1)

    This function tokenizes the sentence pairs using spaCy and remove
    stopwords, defaulting to the spaCy en_core_web_sm model

    Args:
        df (pd.DataFrame): Dataframe with columns sentence_cols to tokenize.
        sentence_cols (list, optional): Column names for the raw sentence
        pairs.
        stop_cols (list, optional): Column names for the tokenized sentences
            without stop words.
        custom_stopwords (list of str, optional): List of custom stopwords to
            register with the spaCy model.

    Returns:
        pd.DataFrame: Dataframe with new columns stop_cols, each containing a
            list of tokens for their respective sentences.
    
utils_nlp/dataset/preprocess.py