<commit_before>import random
import six


def random_crop(img, output_shape, return_slices=False, copy=False):
    """Crop array randomly into `output_shape`.

    All arrays will be cropped by the same region randomly selected. The
    output will all be in shape :obj:`output_shape`.

    Args:
        img (~numpy.ndarray): An image array to be cropped. This is in
            CHW format.
        output_shape (tuple): the size of output image after cropping.
            This value is :math:`(heihgt, width)`.
        return_slices (bool): returns information of slices.
        copy (bool): If False, a view of :obj:`img` is returned.

    Returns:
        This function returns :obj:`out_img, slice_H, slice_W` if
        :obj:`return_slices = True`. Otherwise, this returns
        :obj:`out_img`.

        Note that :obj:`out_img` is the transformed image array.
        Also, :obj:`slice_H` and :obj:`slice_W` are slices used to crop the
        input image. The following relationship is satisfied.

        .. code::

            out_img = img[:, slice_H, slice_W]

    """
    H, W = output_shape

    if img.shape[1] == H:
        start_H = 0
    elif img.shape[1] > H:
        start_H = random.choice(six.moves.range(img.shape[1] - H))
    else:
        raise ValueError('shape of image is larger than output shape')<commit_msg>fix description of arguments<commit_after>import random
import six


def random_crop(img, output_shape, return_slices=False, copy=False):
    """Crop array randomly into `output_shape`.

    All arrays will be cropped by the same region randomly selected. The
    output will all be in shape :obj:`output_shape`.

    Args:
        img (~numpy.ndarray): An image array to be cropped. This is in
            CHW format.
        output_shape (tuple): the size of output image after cropping.
            This value is :math:`(heihgt, width)`.
        return_slices (bool): If :obj:`True`, this function returns
            information of slices.
        copy (bool): If :obj:`False`, a view of :obj:`img` is returned.

    Returns:
        This function returns :obj:`out_img, slice_H, slice_W` if
        :obj:`return_slices = True`. Otherwise, this returns
        :obj:`out_img`.

        Note that :obj:`out_img` is the transformed image array.
        Also, :obj:`slice_H` and :obj:`slice_W` are slices used to crop the
        input image. The following relationship is satisfied.

        .. code::

            out_img = img[:, slice_H, slice_W]

    """
    H, W = output_shape

    if img.shape[1] == H:
        start_H = 0
    elif img.shape[1] > H:
        start_H = random.choice(six.moves.range(img.shape[1] - H))
    else:
        raise ValueError('shape of image is larger than output shape')
{'fraction_non_alphanumeric': 0.10152838427947598, 'fraction_numerical': 0.002911208151382824, 'mean_word_length': 2.5608808290155443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3300501', 'n_tokens_mistral': 831, 'n_tokens_neox': 810, 'n_words': 296}