class_docstr: Gather slices from input ``x`` along dimension ``axis`` according to ``indices``,
  similar to `tf.gather_nd <https://www.tensorflow.org/api_docs/python/tf/gather_nd>`_.
  
  This section documents only the differences between this version and the
  iOS 16 :py:class:`~.iOS16.scatter_gather.gather`. The major differences are as follows:
  
  - Input parameter ``x`` adds support for ``int16``, ``uint16``, ``int8``, and ``uint8``.
  - Input parameter ``indices`` adds support for ``int8`` and ``uint8``.
  - Input parameter ``indices`` now supports only positive values -- negative values
    are considered out-of-bound. If support for negative indices is required, they must be
    explicitly converted to positive values, using the following::
  
       index = iOS17.select(index >= 0, index, index + max_index)
  
  - New input parameter called ``validate_indices`` has been added to all gather ops. Its behavior is as follows:
     - If ``True``, it raises a runtime (possibly also a compile-time) exception for
       out-of-bound values of the ``indices`` parameter.
     - If ``False``, absolutely no checking is performed for out-of-bound values of ``indices``
       either at compile or runtime. Behavior for out-of-bound indices is undefined but memory safe.
  
  Parameters
  ----------
  x: tensor<\*D, T> (Required)
  indices: tensor<\*N, I> (Required)
      * Indices values may be negative. More precisely, ``-D[axis]<= v < D[axis]`` for ``v`` in ``indices``.
  axis: const i32 (Optional. Default=``0``)
      * Negative axis is supported.
  batch_dims: const i32 (Optional. Default=``0``)
      * The number of batch dimensions.
  validate_indices: const bool (Optional)
      * If ``True``, it raises a runtime (possibly also a compile-time) exception
        for out-of-bound values of the ``indices`` parameter.
      * If ``False``, absolutely no checking is performed for out-of-bound values
        of ``indices`` either at compile or runtime. Behavior for out-of-bound indices
        is undefined but memory safe.
      * Default value is ``False``.
  
  Returns
  -------
  tensor<\*K, T>
      * Where ``K = D[:axis] + N[batch_dims:] + D[axis+1:]``.
  
  Attributes
  ----------
  T: fp16, fp32, int32, int16, uint16, int8, uint8
  I: int32, int16, uint16, int8, uint8
class_docstr_tok: ["Gather","slices","from","input","``","x","``","along","dimension","``","axis","``","according","to","``","indices","``",",","similar","to","`","tf.gather_nd","<","https",":","\/\/www.tensorflow.org\/api_docs\/python\/tf\/gather_nd",">","`","_",".","This","section","documents","only","the","differences","between","this","version","and","the","iOS","16",":","py",":","class",":","`","~.iOS16.scatter_gather.gather","`",".","The","major","differences","are","as","follows",":","-","Input","parameter","``","x","``","adds","support","for","``","int16","``",",","``","uint16","``",",","``","int8","``",",","and","``","uint8","``",".","-","Input","parameter","``","indices","``","adds","support","for","``","int8","``","and","``","uint8","``",".","-","Input","parameter","``","indices","``","now","supports","only","positive","values","--","negative","values","are","considered","out-of-bound",".","If","support","for","negative","indices","is","required",",","they","must","be","explicitly","converted","to","positive","values",",","using","the","following",":",":","index","=","iOS17.select","(","index",">","=","0",",","index",",","index","+","max_index",")","-","New","input","parameter","called","``","validate_indices","``","has","been","added","to","all","gather","ops",".","Its","behavior","is","as","follows",":","-","If","``","True","``",",","it","raises","a","runtime","(","possibly","also","a","compile-time",")","exception","for","out-of-bound","values","of","the","``","indices","``","parameter",".","-","If","``","False","``",",","absolutely","no","checking","is","performed","for","out-of-bound","values","of","``","indices","``","either","at","compile","or","runtime",".","Behavior","for","out-of-bound","indices","is","undefined","but","memory","safe",".","Parameters","--","--","--","--","--","x",":","tensor","<","\\","*","D",",","T",">","(","Required",")","indices",":","tensor","<","\\","*","N",",","I",">","(","Required",")","*","Indices","values","may","be","negative",".","More","precisely",",","``","-D","[","axis","]","<","=","v","<","D","[","axis","]","``","for","``","v","``","in","``","indices","``",".","axis",":","const","i32","(","Optional",".","Default=","``","0","``",")","*","Negative","axis","is","supported",".","batch_dims",":","const","i32","(","Optional",".","Default=","``","0","``",")","*","The","number","of","batch","dimensions",".","validate_indices",":","const","bool","(","Optional",")","*","If","``","True","``",",","it","raises","a","runtime","(","possibly","also","a","compile-time",")","exception","for","out-of-bound","values","of","the","``","indices","``","parameter",".","*","If","``","False","``",",","absolutely","no","checking","is","performed","for","out-of-bound","values","of","``","indices","``","either","at","compile","or","runtime",".","Behavior","for","out-of-bound","indices","is","undefined","but","memory","safe",".","*","Default","value","is","``","False","``",".","Returns","--","--","--","-","tensor","<","\\","*","K",",","T",">","*","Where","``","K","=","D","[",":","axis","]","+","N","[","batch_dims",":","]","+","D","[","axis+1",":","]","``",".","Attributes","--","--","--","--","--","T",":","fp16",",","fp32",",","int32",",","int16",",","uint16",",","int8",",","uint8","I",":","int32",",","int16",",","uint16",",","int8",",","uint8"]
code: def type_inference(self):
      result = super().type_inference()
      if self.validate_indices.val:
          indices = self.indices.val
          if indices is not None:
              if np.count_nonzero(
                  np.logical_or(
                      indices < 0,
                      indices >= self.x.shape[self.axis.val],
                  )
              ):
                  raise IndexError(
                      f"Indices is out of bounds for `{self.op_type}` node {self.name}. "
                      f"Expected indices between [0, {self.x.shape[self.axis.val]}), but got {indices}."
                  )
      return result
  
imports: import numpy
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.input_type import DefaultInputs, InputSpec, TensorInputType
  from coremltools.converters.mil.mil.ops.defs._op_reqs import register_op
  from coremltools.converters.mil.mil.ops.defs.iOS15.scatter_gather import scatter
  from coremltools.converters.mil.mil.ops.defs.iOS15.scatter_gather import scatter_along_axis
  from coremltools.converters.mil.mil.ops.defs.iOS15.scatter_gather import scatter_nd
  from coremltools.converters.mil.mil.ops.defs.iOS16.scatter_gather import gather
  from coremltools.converters.mil.mil.ops.defs.iOS16.scatter_gather import gather_along_axis
  from coremltools.converters.mil.mil.ops.defs.iOS16.scatter_gather import gather_nd
  from coremltools.converters.mil.mil.ops.defs.iOS17 import _IOS17_TARGET
label_desc: Use image node_id 2 for calling the gather obj's underlying member method code with example usage: obj.type_inference() and returns: result