<commit_before>local Power, parent = torch.class('nn.Power','nn.Module')

function Power:__init(p)
   parent.__init(self)
   self.pow = p
   if not p then
      error('nn.Power(power)')
   end
end

function Power:updateOutput(input)
   self.output:resizeAs(input):copy(input)
   self.output:pow(self.pow)
   return self.output
end

function Power:updateGradInput(input, gradOutput)
   self.gradInput:resizeAs(input):copy(gradOutput)
   self.gradInput:cmul(self.output):cdiv(input):mul(self.pow)
   return self.gradInput
end<commit_msg>Now you can use power on inputs with 0s. (there is no longer division by 0)<commit_after>local Power, parent = torch.class('nn.Power','nn.Module')

function Power:__init(p)
   parent.__init(self)
   self.pow = p
   if not p then
      error('nn.Power(power)')
   end
end

function Power:updateOutput(input)
   self.output:resizeAs(input):copy(input)
   self.output:pow(self.pow)
   return self.output
end

function Power:updateGradInput(input, gradOutput)
   self.buffer = self.buffer or input.new()
   self.buffer:resizeAs(input):copy(input)
   self.buffer:pow(self.pow - 1)
   self.gradInput:resizeAs(input):copy(gradOutput)
   self.gradInput:cmul(self.buffer):mul(self.pow)
   return self.gradInput
end
{'fraction_non_alphanumeric': 0.1282258064516129, 'fraction_numerical': 0.0024193548387096775, 'mean_word_length': 4.799065420560748, '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': '271011', 'n_tokens_mistral': 425, 'n_tokens_neox': 420, 'n_words': 83}