class_docstr: Slicing input tensor with given ``size`` for each rank.
  
  Parameters
  ----------
  x: tensor<*?, T> (Required)
      * Input tensor.
  begin: tensor<[rank(x)], i32> Required
      * The begin index for slice.
  size: tensor<[rank(x)], i32> Required
      * The size that is to be sliced. If ``size`` is ``-1``, we slice all the remaining elements.
  
  Returns
  -------
  tensor<*?, T>
      * Scalar or tensor. Same type as the input tensor.
  
  Attributes
  ----------
  T: fp32
code: def type_inference(self):
      if self.begin.rank != 1:
          raise ValueError(
              "begin should be 1-D tensor, got {}-D tensor instead".format(
                  self.begin.rank
              )
          )
      if self.size.rank != 1:
          raise ValueError(
              "size should be 1-D tensor, got {}-D tensor instead".format(
                  self.size.rank
              )
          )
      if self.x.rank != self.begin.shape[0]:
          raise ValueError(
              "Length of begin {} doesn't equal to input rank {}.".format(
                  len(self.begin.shape[0]), len(self.x.rank)
              )
          )
      if self.x.rank != self.size.shape[0]:
          raise ValueError(
              "Length of size {} doesn't equal to input rank {}.".format(
                  len(self.size.shape[0]), len(self.x.rank)
              )
          )
  
      x_shape = self.x.shape
      ret_shape = []
      if self.size.sym_val is None:
          ret_shape = [get_new_symbol() for _ in range(self.x.rank)]
          return types.tensor(self.x.dtype, tuple(ret_shape))
  
      for idx, s in enumerate(self.size.sym_val):
          if is_symbolic(s):
              ret_shape.append(s)
          elif s != -1:
              ret_shape.append(s)
          elif self.begin.sym_val is not None:
              ret_shape.append(x_shape[idx] - self.begin.sym_val[idx])
          else:
              ret_shape.append(get_new_symbol())
  
      return types.tensor(self.x.dtype, tuple(ret_shape))
  
imports: import functools
  import sympy
  from coremltools.converters.mil.mil.types.symbolic import is_symbolic, isscalar, any_symbolic, any_variadic
  from coremltools.converters.mil.mil import get_new_symbol, get_new_variadic_symbol, VALUE, SYMBOL, types
  from ._op_reqs import *
label_desc: Use image node_id 2 for calling the slice_by_size obj's underlying member method code with example usage: obj.type_inference() and returns: types, types