class_docstr: Method for numpy style indexing and slicing.
  Suppose we have a tensor ``x``, this method achieves:
  ``result = x[begin[0]: end[0]: stride[0], begin[1]: end[1]: stride[1], ...]``
  Note this method does not support pure indexing. You would need to do squeeze if indexing is intended.
  
  Parameters
  ----------
  x: tensor<*?, T> (Required)
      * Input tensor
  begin: tensor<[rank<x>], i32> (Required)
      * Starting index for the dimension of slicing.
  end: tensor<[rank(x)], i32> (Required)
      * Ending index for the dimension of slicing.
  stride: tensor<[rank(x)], i32> (Optional)
      * Default as all ``1``s.
      * Stride for the dimension of slicing.
  begin_mask: tensor<[rank(x)], bool> (Optional)
      * Default to all ``False``.
      * If ``begin_mask[i]==True``, neglect ``begin[i]``, and set ``begin[i]`` to ``0``.
  end_mask: tensor<[rank(x)], bool> (Optional)
      * Default to all ``False``.
      * If ``end_mask[i]==True``, neglect ``end[i]``, and set ``end[i]`` to ``x.shape[i]``.
  squeeze_mask: tensor<[rank(x)], bool> (Optional)
      * Default to all ``False``.
      * If ``squeeze_mask[i]==true``, neglect ``end[i]``, and do the pure index at ``begin[i]``.
  
  Returns
  -------
  tensor<*?, T>
      - Scalar or tensor.
  
  Attributes
  ----------
  T: fp32
code: def value_inference(self):
      if (
          self.x.sym_val is None
          or self.begin.val is None
          or self.end.val is None
      ):
          return None
      x_shape = self.x.shape
      begin = [int(i) for i in list(self.begin.val[:])]
      end = [int(i) for i in list(self.end.val[:])]
      stride = (
          [1] * self.x.rank if self.stride is None else self.stride.val
      )
      begin_mask = (
          [False] * self.x.rank
          if self.begin_mask is None
          else self.begin_mask.val
      )
      end_mask = (
          [False] * self.x.rank
          if self.end_mask is None
          else self.end_mask.val
      )
      squeeze_mask = (
          [False] * self.x.rank
          if self.squeeze_mask is None
          else self.squeeze_mask.val
      )
  
      slices = []
      for idx, mask in enumerate(begin_mask):
          if mask:
              begin[idx] = None
      for idx, mask in enumerate(end_mask):
          if mask:
              end[idx] = None
      squeeze_axes = []
      for idx, mask in enumerate(squeeze_mask):
          if mask:
              end[idx] = None
              stride[
                  idx
              ] = 2147483647  # We slice out only 1 element by setting stride to INF
              squeeze_axes.append(idx)
      for idx in range(self.x.rank):
          slices.append(slice(begin[idx], end[idx], stride[idx]))
  
      slices = tuple(slices)
      res = self.x.sym_val[slices]
  
      # remove squeezed axes
      if len(squeeze_axes) > 0:
          if len(squeeze_axes) == len(res.shape):
              if len(res) == 0:
                  logging.warning(
                      "%s seems to be a 0 sized tensor", self.name
                  )
                  return np.array([])
              res = res.tolist()[0]
              if is_symbolic(res):
                  return res
              elif (
                  self.x.dtype == types.int32
                  or self.x.dtype == types.int64
              ):
                  res = np.int32(res)
              elif (
                  self.x.dtype == types.float
                  or self.x.dtype == types.double
              ):
                  res = np.float32(res)
              else:
                  raise ValueError(
                      "Unable to convert type {}".format(
                          self.x.sym_val.dtype
                      )
                  )
          else:
              res = np.squeeze(res, axis=tuple(squeeze_axes))
      return res
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/mil/ops/defs/slicend.py
imports: from __future__ import division
  from coremltools.converters.mil.mil.types.symbolic import is_symbolic
  from coremltools.converters.mil.mil import get_new_symbol
  from ._op_reqs import *
label_desc: Use image node_id 3 for calling the slice_by_index obj's underlying member method code with example usage: obj.value_inference() and returns: res, None, np, res