'x.__getitem__(i) <=> x[i]
Returns a sliced view of this array.
Parameters
key : int or slice
Indexing key.
Examples
>>> x = mx.nd.arange(0,6).reshape((2,3))
>>> x.asnumpy()
array([[ 0.,  1.,  2.],
[ 3.,  4.,  5.]], dtype=float32)
>>> x[1].asnumpy()
array([ 3.,  4.,  5.], dtype=float32)
>>> y = x[0:1]
>>> y[:] = 2
>>> x.asnumpy()
array([[ 2.,  2.,  2.],
[ 3.,  4.,  5.]], dtype=float32)'

def __getitem__(self, key):

    if isinstance(key, integer_types):
        if (key > (self.shape[0] - 1)):
            raise IndexError('index    {}    is    out    of    bounds    for    axis    0    with    size    {}'.format(key, self.shape[0]))
        return self._at(key)
    elif isinstance(key, py_slice):
        if (key.step is not None):
            raise ValueError('NDArray    only    supports    slicing    with    step    size    1.')
        if ((key.start is not None) or (key.stop is not None)):
            return self._slice(key.start, key.stop)
        else:
            return self
    elif isinstance(key, tuple):
        shape = self.shape
        oshape = []
        begin = []
        end = []
        assert (len(shape) >= len(key)), ('Slicing    dimensions    exceeds    array    dimensions,    %d    vs    %d' % (len(key), len(shape)))
        i = (-1)
        for (i, slice_i) in enumerate(key):
            if isinstance(slice_i, integer_types):
                begin.append(slice_i)
                end.append((slice_i + 1))
            elif isinstance(slice_i, py_slice):
                if (slice_i.step is not None):
                    raise ValueError('NDArray    only    supports    slicing    with    step    size    1.')
                begin.append((0 if (slice_i.start is None) else slice_i.start))
                end.append((shape[i] if (slice_i.stop is None) else slice_i.stop))
                oshape.append((end[i] - begin[i]))
            else:
                raise ValueError(('NDArray    does    not    support    slicing    with    key    %s    of    type    %s.' % (str(slice_i), str(type(slice_i)))))
        oshape.extend(shape[(i + 1):])
        if (len(oshape) == 0):
            oshape.append(1)
        return slice(self, begin, end).reshape(oshape)
    else:
        raise ValueError(('NDArray    does    not    support    slicing    with    key    %s    of    type    %s.' % (str(key), str(type(key)))))
