<commit_before>

import chainer
from chainer import training, Variable, ChainList
from chainer import reporter as reporter_module
from chainer.training import extensions
import copy

class MyUpdater(training.StandardUpdater):
    def update_core(self):
        batch = self._iterators['main'].next()
        optimizer = self._optimizers['main']
        loss_func = self.loss_func or optimizer.target
        optimizer.update(loss_func, self.converter(batch, self.device))


class MyEvaluator(extensions.Evaluator):
    def evaluate(self):
        iterator = self._iterators['main']
        target = self._targets['main']
        eval_func = self.eval_func or target
        if self.eval_hook:
            self.eval_hook(self)
        it = copy.copy(iterator)
        summary = reporter_module.DictSummary()

        for batch in it:
            observation = {}
            with reporter_module.report_scope(observation):
                eval_func(*self.converter(batch, self.device))
            summary.add(observation)
        return summary.compute_mean()

<commit_msg>fix a bug in updater<commit_after>

import chainer
from chainer import training, Variable, ChainList
from chainer import reporter as reporter_module
from chainer.training import extensions
import copy

class MyUpdater(training.StandardUpdater):
    def update_core(self):
        batch = self._iterators['main'].next()
        optimizer = self._optimizers['main']
        loss_func = self.loss_func or optimizer.target
        optimizer.update(loss_func, self.converter(batch, self.device))


class MyEvaluator(extensions.Evaluator):
    def evaluate(self):
        iterator = self._iterators['main']
        target = self._targets['main']
        eval_func = self.eval_func or target
        if self.eval_hook:
            self.eval_hook(self)
        it = copy.copy(iterator)
        summary = reporter_module.DictSummary()

        for batch in it:
            observation = {}
            with reporter_module.report_scope(observation):
                eval_func(self.converter(batch, self.device))
            summary.add(observation)
        return summary.compute_mean()


{'fraction_non_alphanumeric': 0.0887546468401487, 'fraction_numerical': 0.0, 'mean_word_length': 2.8933092224231465, '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': '2317829', 'n_tokens_mistral': 592, 'n_tokens_neox': 586, 'n_words': 138}