Rescale the gradient of provided parameters by a certain scale

def rescale_grad(self, scale=None, param_name=None):
        """ Rescale the gradient of provided parameters by a certain scale """
        if scale is None or param_name is None:
            return
        param_idx = self._exec_group.param_names.index(param_name)
        grad_vals = self._exec_group.grad_arrays[param_idx]
        for grad in grad_vals:
            grad[:] *= scale