'Compute the cost function over the inputs and targets.
Arguments:
inputs (Tensor): Tensor containing input values to be compared to
targets
targets_mask ((Tensor, Tensor)): Tuple with Tensor target values and Tensor mask
Returns:
Tensor containing cost'

def get_cost(self, inputs, targets_mask):

    (targets, mask) = targets_mask
    masked_input = (inputs * mask)
    masked_targets = (targets * mask)
    self.outputs[:] = self.costfunc(masked_input, masked_targets)
    self.cost_buffer[:] = (self.be.mean(self.outputs, axis=1) * self.weights)
    self.cost[:] = self.cost_buffer.get()
    return self.cost
