<commit_before>import numpy

from chainer import cuda
from chainer import function
from chainer.utils import type_check


class Gaussian(function.Function):

    """Gaussian sampling function.

    It takes mean and log(variance) as input and output sample drawn from
    gaussian N(mean, variance).

    """

    def __init__(self):
        self.eps = None

    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 2)

        m_type, v_type = in_types
        type_check.expect(
            m_type.dtype == numpy.float32,
            v_type.dtype == numpy.float32,
            m_type.shape == v_type.shape,
        )

    def check_type_fbackward(self, in_types, out_types):
        type_check.expect(out_types.size() == 1)
        m_type, v_type = in_types
        g_type, = out_types

        type_check.expect(
            g_type.dtype == numpy.float32,
            g_type.shape == m_type.shape,
        )

    def check_type_backward(self, in_types, out_types):
        type_check.expect(out_types.size() == 1)

    def forward_cpu(self, inputs):
        mean, ln_var = inputs
        if self.eps is None:
            self.eps = numpy.random.normal(0, 1, ln_var.shape) \
                                   .astype(numpy.float32)

        self.noise = numpy.exp(ln_var * 0.5) * self.eps<commit_msg>Fix typo<commit_after>import numpy

from chainer import cuda
from chainer import function
from chainer.utils import type_check


class Gaussian(function.Function):

    """Gaussian sampling function.

    It takes mean and log(variance) as input and output sample drawn from
    gaussian N(mean, variance).

    """

    def __init__(self):
        self.eps = None

    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 2)

        m_type, v_type = in_types
        type_check.expect(
            m_type.dtype == numpy.float32,
            v_type.dtype == numpy.float32,
            m_type.shape == v_type.shape,
        )

    def check_type_backward(self, in_types, out_types):
        type_check.expect(out_types.size() == 1)
        m_type, v_type = in_types
        g_type, = out_types

        type_check.expect(
            g_type.dtype == numpy.float32,
            g_type.shape == m_type.shape,
        )

    def forward_cpu(self, inputs):
        mean, ln_var = inputs
        if self.eps is None:
            self.eps = numpy.random.normal(0, 1, ln_var.shape) \
                                   .astype(numpy.float32)

        self.noise = numpy.exp(ln_var * 0.5) * self.eps
{'fraction_non_alphanumeric': 0.09812353401094605, 'fraction_numerical': 0.011336982017200938, 'mean_word_length': 2.136029411764706, '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': '7364693', 'n_tokens_mistral': 845, 'n_tokens_neox': 800, 'n_words': 182}