

def grad(self, inputs, gout):
    (gz,) = gout
    is_continuous = [(inputs[i].dtype in tensor.continuous_dtypes) for i in range(len(inputs))]
    if _is_sparse_variable(gz):
        gz = dense_from_sparse(gz)
    split = tensor.Split(len(inputs))(gz, 0, tensor.stack([x.shape[0] for x in inputs]))
    if (not isinstance(split, list)):
        split = [split]
    derivative = [SparseFromDense(self.format)(s) for s in split]

    def choose(continuous, derivative):
        if continuous:
            return derivative
        else:
            return None
    return [choose(c, d) for (c, d) in zip(is_continuous, derivative)]

dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/sparse/basic.py VStack.grad/original