

def make_node(self, x, index):
    scipy_ver = [int(n) for n in scipy.__version__.split('.')[:2]]
    x = as_sparse_variable(x)
    assert (x.format in ['csr', 'csc'])
    assert (len(index) in [1, 2])
    input_op = [x]
    generic_None = theano.gof.Constant(theano.gof.generic, None)
    for ind in index:
        if isinstance(ind, slice):
            start = ind.start
            stop = ind.stop
            step = ind.step
            if ((scipy_ver < [0, 14]) and (ind.step is not None)):
                raise ValueError('Slice with step is not support with current version of Scipy.')
            if ((ind.step is None) or (ind.step == 1)):
                step = generic_None
            else:
                if (not isinstance(step, gof.Variable)):
                    step = tensor.as_tensor_variable(step)
                if (not ((step.ndim == 0) and (step.dtype in tensor.discrete_dtypes))):
                    raise ValueError(('Impossible to index into a sparse matrix with slice where step=%s' % step), step.ndim, step.dtype)
            if (start is None):
                start = generic_None
            else:
                if (not isinstance(start, gof.Variable)):
                    start = tensor.as_tensor_variable(start)
                if (not ((start.ndim == 0) and (start.dtype in tensor.discrete_dtypes))):
                    raise ValueError(('Impossible to index into a sparse matrix with slice where start=%s' % start), start.ndim, start.dtype)
            if (stop is None):
                stop = generic_None
            else:
                if (not isinstance(stop, gof.Variable)):
                    stop = tensor.as_tensor_variable(stop)
                if (not ((stop.ndim == 0) and (stop.dtype in tensor.discrete_dtypes))):
                    raise ValueError(('Impossible to index into a sparse matrix with slice where stop=%s' % stop), stop.ndim, stop.dtype)
        elif ((isinstance(ind, gof.Variable) and (getattr(ind, 'ndim', (- 1)) == 0)) or numpy.isscalar(ind)):
            raise NotImplementedError(('Theano has no sparse vector' + 'Use X[a:b, c:d], X[a:b, c:c+1] or X[a:b] instead.'))
        else:
            raise ValueError(('Advanced indexing is not implemented for sparse matrices. Argument not supported: %s' % ind))
        input_op += [start, stop, step]
    if (len(index) == 1):
        input_op += [generic_None, generic_None, generic_None]
    return gof.Apply(self, input_op, [x.type()])

dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/sparse/basic.py GetItem2d.make_node/original