<commit_before>import numpy as np
import warnings

from chainer.serializers import NpzDeserializer
from chainercv.utils import download_model

try:
    import cv2  # NOQA
    _available = True
except ImportError:
    _available = False


def prepare_pretrained_model(param, pretrained_model, models, default={}):
    """Select parameters based on the existence of pretrained model.

    Args:
        param (dict): Map from the name of the parameter to values.
        pretrained_model (string): Name of the pretrained weight,
            path to the pretrained weight or :obj:`None`.
        models (dict): Map from the name of the pretrained weight
            to :obj:`model`, which is a dictionary containing the
            configuration used by the selected weight.

            :obj:`model` has four keys: :obj:`param`, :obj:`overwritable`,
            :obj:`url` and :obj:`cv2`.

            * **param** (*dict*): Parameters assigned to the pretrained \
                weight.
            * **overwritable** (*set*): Names of parameters that are \
                overwritable (i.e., :obj:`param[key] != model['param'][key]` \
                is accepted).
            * **url** (*string*): Location of the pretrained weight.
            * **cv2** (*bool*): If :obj:`True`, a warning is raised \<commit_msg>flake8 link.py<commit_after>import warnings

from chainercv.utils import download_model

try:
    import cv2  # NOQA
    _available = True
except ImportError:
    _available = False


def prepare_pretrained_model(param, pretrained_model, models, default={}):
    """Select parameters based on the existence of pretrained model.

    Args:
        param (dict): Map from the name of the parameter to values.
        pretrained_model (string): Name of the pretrained weight,
            path to the pretrained weight or :obj:`None`.
        models (dict): Map from the name of the pretrained weight
            to :obj:`model`, which is a dictionary containing the
            configuration used by the selected weight.

            :obj:`model` has four keys: :obj:`param`, :obj:`overwritable`,
            :obj:`url` and :obj:`cv2`.

            * **param** (*dict*): Parameters assigned to the pretrained \
                weight.
            * **overwritable** (*set*): Names of parameters that are \
                overwritable (i.e., :obj:`param[key] != model['param'][key]` \
                is accepted).
            * **url** (*string*): Location of the pretrained weight.
            * **cv2** (*bool*): If :obj:`True`, a warning is raised \
{'fraction_non_alphanumeric': 0.10989867498051442, 'fraction_numerical': 0.0027279812938425566, 'mean_word_length': 2.5164383561643837, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5412667', 'n_tokens_mistral': 687, 'n_tokens_neox': 671, 'n_words': 259}