<commit_before>import os
import tempfile
import unittest
import warnings

import mock
import numpy
import six

import chainer
from chainer import links
from chainer import testing


# The caffe submodule relies on protobuf which under protobuf==3.7.0 and
# Python 3.7 raises a DeprecationWarning from the collections module.
with warnings.catch_warnings():
    warnings.filterwarnings(action='ignore', category=DeprecationWarning)
    from chainer.links import caffe
    from chainer.links.caffe.caffe_function import caffe_pb


def _iter_init(param, data):
    if isinstance(data, list):
        for d in data:
            if hasattr(param, 'append'):
                param.append(d)
            else:
                param.add()
                if isinstance(d, (list, dict)):
                    _iter_init(param[-1], d)
                else:
                    param[-1] = d

    elif isinstance(data, dict):
        for k, d in data.items():
            if isinstance(d, (list, dict)):
                _iter_init(getattr(param, k), d)
            else:
                setattr(param, k, d)

    else:<commit_msg>Fix caffe test with protobuf>=3.8<commit_after>import os
import tempfile
import unittest
import warnings

import mock
import numpy
import six

import chainer
from chainer import links
from chainer import testing


# The caffe submodule relies on protobuf which under protobuf==3.7.0 and
# Python 3.7 raises a DeprecationWarning from the collections module.
with warnings.catch_warnings():
    warnings.filterwarnings(action='ignore', category=DeprecationWarning)
    from chainer.links import caffe
    from chainer.links.caffe.caffe_function import caffe_pb


def _iter_init(param, data):
    if isinstance(data, list):
        for d in data:
            if hasattr(param, 'add'):
                param.add()
                if isinstance(d, (list, dict)):
                    _iter_init(param[-1], d)
                else:
                    param[-1] = d
            else:
                param.append(d)

    elif isinstance(data, dict):
        for k, d in data.items():
            if isinstance(d, (list, dict)):
                _iter_init(getattr(param, k), d)
            else:
                setattr(param, k, d)

    else:
{'fraction_non_alphanumeric': 0.08566355969818021, 'fraction_numerical': 0.007101642254771416, 'mean_word_length': 2.2017045454545454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4245554', 'n_tokens_mistral': 653, 'n_tokens_neox': 619, 'n_words': 203}