<commit_before>import os
import tempfile
import unittest

import numpy

import chainer
from chainer import links
from chainer.testing import attr
from chainer import training


class Model(chainer.Chain):

    def __init__(self):
        super(Model, self).__init__()
        with self.init_scope():
            self.l = links.Linear(1, 3)

    def __call__(self, x):
        return self.l(x)


class Dataset(chainer.dataset.DatasetMixin):

    def __init__(self, values):
        self.values = values

    def __len__(self):
        return len(self.values)

    def get_example(self, i):
        return numpy.array([self.values[i]], numpy.float32), numpy.int32(i % 2)


class TestNanKiller(unittest.TestCase):

    def setUp(self):
        self.n_data = 4
        self.n_epochs = 3

        self.model = Model()
        self.classifier = links.Classifier(self.model)
        self.optimizer = chainer.optimizers.Adam()
        self.optimizer.setup(self.classifier)

        self.dataset = Dataset([i for i in range(self.n_data)])
        self.iterator = chainer.iterators.SerialIterator(
            self.dataset, 1, shuffle=False)

    def prepare(self, device=None):
        tempdir = tempfile.mkdtemp()
        outdir = os.path.join(tempdir, 'testresult')
        self.updater = training.updaters.StandardUpdater(
            self.iterator, self.optimizer, device=device)
        self.trainer = training.Trainer(<commit_msg>Fix typo<commit_after>import os
import tempfile
import unittest

import numpy

import chainer
from chainer import links
from chainer.testing import attr
from chainer import training


class Model(chainer.Chain):

    def __init__(self):
        super(Model, self).__init__()
        with self.init_scope():
            self.l = links.Linear(1, 3)

    def __call__(self, x):
        return self.l(x)


class Dataset(chainer.dataset.DatasetMixin):

    def __init__(self, values):
        self.values = values

    def __len__(self):
        return len(self.values)

    def get_example(self, i):
        return numpy.array([self.values[i]], numpy.float32), numpy.int32(i % 2)


class TestNaNKiller(unittest.TestCase):

    def setUp(self):
        self.n_data = 4
        self.n_epochs = 3

        self.model = Model()
        self.classifier = links.Classifier(self.model)
        self.optimizer = chainer.optimizers.Adam()
        self.optimizer.setup(self.classifier)

        self.dataset = Dataset([i for i in range(self.n_data)])
        self.iterator = chainer.iterators.SerialIterator(
            self.dataset, 1, shuffle=False)

    def prepare(self, device=None):
        tempdir = tempfile.mkdtemp()
        outdir = os.path.join(tempdir, 'testresult')
        self.updater = training.updaters.StandardUpdater(
            self.iterator, self.optimizer, device=device)
        self.trainer = training.Trainer(
{'fraction_non_alphanumeric': 0.10740610740610741, 'fraction_numerical': 0.00702000702000702, 'mean_word_length': 2.7401574803149606, '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': '1374418', 'n_tokens_mistral': 912, 'n_tokens_neox': 875, 'n_words': 196}