<commit_before>from .lazy_variable import LazyVariable
from .non_lazy_variable import NonLazyVariable
from ..posterior import DefaultPosteriorStrategy
import torch
from torch.autograd import Variable
from ..utils.trace import trace_components
from gpytorch.utils import StochasticLQ


class MulLazyVariable(LazyVariable):
    def __init__(self, *lazy_vars, **kwargs):
        '''
        Args:
            - lazy_vars (A list of LazyVariable) - A list of LazyVariable to multiplicate with.
            - matmul_mode (String) - deterministic(default), stochastic or approximate
            - max_iter (int) - the maximum iteration in lanczos decomposition in when matmul_mode=approximate
            - num_samples (int) - the samples number when matmul_mode=stochastic
        '''
        lazy_vars = list(lazy_vars)
        for i, lazy_var in enumerate(lazy_vars):
            if not isinstance(lazy_var, LazyVariable):
                if isinstance(lazy_var, Variable):
                    lazy_vars[i] = NonLazyVariable(lazy_var)
                else:
                    raise RuntimeError('All arguments of a SumLazyVariable should be lazy variables or vairables')
        super(MulLazyVariable, self).__init__(*lazy_vars, **kwargs)

        self.lazy_vars = lazy_vars

        if 'matmul_mode' in kwargs:
            self.matmul_mode = kwargs['matmul_mode']
        else:
            self.matmul_mode = 'deterministic'

        if 'added_diag' in kwargs:
            self.added_diag = kwargs['added_diag']
        else:
            self.added_diag = None

        if 'max_iter' in kwargs:
            self.max_iter = kwargs['max_iter']
        else:
            self.max_iter = 15

        if self.matmul_mode == 'approximate':
            if len(lazy_vars) > 1:
                half_d = int(len(lazy_vars) / 2)<commit_msg>Fix error message for MulLazyVariable<commit_after>from .lazy_variable import LazyVariable
from .non_lazy_variable import NonLazyVariable
from ..posterior import DefaultPosteriorStrategy
import torch
from torch.autograd import Variable
from ..utils.trace import trace_components
from gpytorch.utils import StochasticLQ


class MulLazyVariable(LazyVariable):
    def __init__(self, *lazy_vars, **kwargs):
        '''
        Args:
            - lazy_vars (A list of LazyVariable) - A list of LazyVariable to multiplicate with.
            - matmul_mode (String) - deterministic(default), stochastic or approximate
            - max_iter (int) - the maximum iteration in lanczos decomposition in when matmul_mode=approximate
            - num_samples (int) - the samples number when matmul_mode=stochastic
        '''
        lazy_vars = list(lazy_vars)
        for i, lazy_var in enumerate(lazy_vars):
            if not isinstance(lazy_var, LazyVariable):
                if isinstance(lazy_var, Variable):
                    lazy_vars[i] = NonLazyVariable(lazy_var)
                else:
                    raise RuntimeError('All arguments of a MulLazyVariable should be lazy variables or vairables')
        super(MulLazyVariable, self).__init__(*lazy_vars, **kwargs)

        self.lazy_vars = lazy_vars

        if 'matmul_mode' in kwargs:
            self.matmul_mode = kwargs['matmul_mode']
        else:
            self.matmul_mode = 'deterministic'

        if 'added_diag' in kwargs:
            self.added_diag = kwargs['added_diag']
        else:
            self.added_diag = None

        if 'max_iter' in kwargs:
            self.max_iter = kwargs['max_iter']
        else:
            self.max_iter = 15

        if self.matmul_mode == 'approximate':
            if len(lazy_vars) > 1:
                half_d = int(len(lazy_vars) / 2)
{'fraction_non_alphanumeric': 0.07771739130434782, 'fraction_numerical': 0.002173913043478261, 'mean_word_length': 2.3677950594693504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3848815', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1048, 'n_words': 281}