<commit_before>import theano.tensor as T


class EnergyFunction(object):
    def __init__(self):
        pass
    #

    def score(self, X):
        assert X.dtype.find('int') == -1

        X_name = 'X' if X.name is None else X.name

        E = self.free_energy(X)

        #There should be one energy value for each example in the batch
        assert len(E.type.broadcastable) == 1

        dummy = T.sum(E)
        rval =  T.grad(dummy,X)

        rval.name = 'score('+X_name+')'

        return rval
    #

    def __call__(self, X):
        raise NotImplementedError(str(type(self))+' has not implemented __call__(self,X) which should return the energy of X')
    #
#<commit_msg>added more virtual functions to EnergyFunction<commit_after>import theano.tensor as T


class EnergyFunction(object):
    def __init__(self):
        pass
    #

    def score(self, X):
        assert X.dtype.find('int') == -1

        X_name = 'X' if X.name is None else X.name

        E = self.free_energy(X)

        #There should be one energy value for each example in the batch
        assert len(E.type.broadcastable) == 1

        dummy = T.sum(E)
        rval =  T.grad(dummy,X)

        rval.name = 'score('+X_name+')'

        return rval
    #

    def free_energy(self, X):
        raise NotImplementedError(str(type(self))+' has not implemented free_energy(self,X)' )
    #

    def energy(self, varlist):
        raise NotImplementedError(str(type(self))+' has not implemented energy(self,varlist)' )
    #

    def __call__(self, varlist):
        return self.energy(varlist)
    #
#
{'fraction_non_alphanumeric': 0.11412358133669609, 'fraction_numerical': 0.0025220680958385876, 'mean_word_length': 2.376595744680851, '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': '6335590', 'n_tokens_mistral': 523, 'n_tokens_neox': 505, 'n_words': 140}