<commit_before>import time
import sys
import numpy as np

from functools import partial


def np_minmax(func1, func2, X, axis=None):

    if axis is None:
        return func1(X)
    else:
        return func1(X, axis), func2(X, axis)

np_min = partial(np_minmax, np.min, np.argmin)
np_max = partial(np_minmax, np.max, np.argmax)


def expo(value, current_step, total_steps):
    """
    Decrease a value X_0 according to an exponential function.

    Lambda is equal to (-2.5 * (current_step / total_steps))

    :param value: The original value.
    :param current_step: The current timestep.
    :param total_steps: The maximum number of steps.
    :return:
    """
    return value * np.exp(-2.5 * (current_step / total_steps))


def static(value, current_step, total_steps):
    """
    Static function: nothing changes.

    :param value: the value
    :return:
    """
    return value


def linear(value, current_step, total_steps):
    """
    Decrease a value X_0 according to a linear function.

    :param value: The original value.<commit_msg>Resize<commit_after>import time
import sys
import numpy as np

from functools import partial


def np_minmax(func1, func2, X, axis=None):

    if axis is None:
        return func1(X)
    else:
        return func1(X, axis), func2(X, axis)

np_min = partial(np_minmax, np.min, np.argmin)
np_max = partial(np_minmax, np.max, np.argmax)


def resize(X, new_shape):
    """
    Dummy resize function because cupy currently does
    not support direct resizing of arrays.

    :param X: The input data
    :param new_shape: The desired shape of the array.
    Must have the same dimensions as X.
    :return: A resized array.
    """

    # Difference between actual and desired size
    length_diff = (new_shape[0] * new_shape[1]) - len(X)

    # Pad input data with zeros
    z = np.concatenate([X, np.zeros((length_diff, X.shape[1]))])

    # Reshape
    return z.reshape(new_shape)


def expo(value, current_step, total_steps):
    """
    Decrease a value X_0 according to an exponential function.

    Lambda is equal to (-2.5 * (current_step / total_steps))

    :param value: The original value.
    :param current_step: The current timestep.
    :param total_steps: The maximum number of steps.
    :return:
    """
    return value * np.exp(-2.5 * (current_step / total_steps))


def static(value, current_step, total_steps):
    """
    Static function: nothing changes.

    :param value: the value
    :return:
    """
    return value


def linear(value, current_step, total_steps):
    """
    Decrease a value X_0 according to a linear function.

    :param value: The original value.
{'fraction_non_alphanumeric': 0.09917043740573152, 'fraction_numerical': 0.00942684766214178, 'mean_word_length': 3.0878274268104775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6368202', 'n_tokens_mistral': 879, 'n_tokens_neox': 847, 'n_words': 287}