'Extract a subset view of the items via slice style indexing
along each dimension. e.g. A[5:10, :].  Each slice consists of
start_idx:stop_idx:step_size triplets.  If step_size isn\'t specified it
defaults to 1.  If start_idx isn\'t specified it defaults to 0.  If
stop_idx isn\'t specified it defaults to the total number of elements
along that dimension.  As such a slice value of \':\' allows one to
select all elements along that dimension. To be consistent with GPU
Tensors, CPU Tensors remove the axis that has size 1 unless it needs to
maintain 2D.
Arguments:
key (int, slice, tuple): indices of each dimension\'s slice.
Returns:
CPUTensor: view of self corresponding to the subset items.'

def __getitem__(self, key):

    if (not isinstance(key, tuple)):
        if (key == _none_slice):
            return self
        key = (key,)
    key_list = list(key)
    for (idx, k) in enumerate(key):
        if (type(k) is int):
            k = ((self.shape[idx] + k) if (k < 0) else k)
            key_list[idx] = slice(k, (k + 1), None)
    key = tuple(key_list)
    new_shape = list(self._tensor[key].shape)
    for (idx, k) in enumerate(new_shape):
        if ((len(new_shape) > 2) and (k is 1)):
            new_shape.remove(k)
    return self.__class__(backend=self.backend, ary=self._tensor[key].reshape(new_shape), dtype=self._tensor.dtype, base=self)
