class_docstr: A version of ``topk`` for iOS 17+. The differences between this version and the
  iOS 16 :py:class:`~.iOS16.tensor_operation.topk` are:
  
     - New data type support. The newly added data types are:
        - int8, uint8, int16, unint16 for ``x`` and output.
        - int8, int16 for ``k``.
     - Validation restrictions on the optional ``indices`` output must be either
       uint16 or int32.
     - A new input parameter ``output_indices_dtype`` has been added
       to set the dtype of output ``indices``.
  
  Parameters
  ----------
  x: <\*?, T> (Required)
      * Input tensor.
  k: const<K> (Optional)
      * Defaults to ``1``.
      * Number of values/indices to be computed along each axis.
      * Set to ``-1`` to select all elements.
  axis: const<i32> (Optional)
      * Defaults to ``-1`` (last dimension).
      * Axis to perform the operation.
  ascending: const<bool> (Optional)
      * Defaults to ``False``, sort in descending order.
      * ``True`` to sort in ascending order.
  sort: const<bool> (Optional)
      * Defaults to ``True``.
      * If ``True``, ``top-k`` elements are themselves sorted.
        Otherwise, no particular ordering is guaranteed.
  return_indices: const<bool> (Optional)
      * Defaults to ``True``.
      * If ``True``, returns both values and indices. Otherwise, returns only the ``top-k`` values.
  output_indices_dtype: const<str> (Optional, default="int32")
      * It can only be set when ``return_indices`` is ``True``.
      * This parameter can take ``"int32"`` or ``"uint16"`` as values.
  
  Returns
  -------
  tensor<\*?, T>
      * Values of top/bottom ``k`` elements.
  
  tensor<\*?, U>
      * Only returned when ``return_indices = True``
      * Indices of the top/bottom ``k`` elements along axis.
      * U is int32 or uint16 determined by ``output_indices_dtype`` (int32 by default).
  
  Attributes
  ----------
  T: fp16, fp32, int8, int16, int32, uint8, uint16
  K: int8, int16, int32
class_docstr_tok: ["A","version","of","``","topk","``","for","iOS","17+",".","The","differences","between","this","version","and","the","iOS","16",":","py",":","class",":","`","~.iOS16.tensor_operation.topk","`","are",":","-","New","data","type","support",".","The","newly","added","data","types","are",":","-","int8",",","uint8",",","int16",",","unint16","for","``","x","``","and","output",".","-","int8",",","int16","for","``","k","``",".","-","Validation","restrictions","on","the","optional","``","indices","``","output","must","be","either","uint16","or","int32",".","-","A","new","input","parameter","``","output_indices_dtype","``","has","been","added","to","set","the","dtype","of","output","``","indices","``",".","Parameters","--","--","--","--","--","x",":","<","\\","*","?",",","T",">","(","Required",")","*","Input","tensor",".","k",":","const","<","K",">","(","Optional",")","*","Defaults","to","``","1","``",".","*","Number","of","values\/indices","to","be","computed","along","each","axis",".","*","Set","to","``","-1","``","to","select","all","elements",".","axis",":","const","<","i32",">","(","Optional",")","*","Defaults","to","``","-1","``","(","last","dimension",")",".","*","Axis","to","perform","the","operation",".","ascending",":","const","<","bool",">","(","Optional",")","*","Defaults","to","``","False","``",",","sort","in","descending","order",".","*","``","True","``","to","sort","in","ascending","order",".","sort",":","const","<","bool",">","(","Optional",")","*","Defaults","to","``","True","``",".","*","If","``","True","``",",","``","top-k","``","elements","are","themselves","sorted",".","Otherwise",",","no","particular","ordering","is","guaranteed",".","return_indices",":","const","<","bool",">","(","Optional",")","*","Defaults","to","``","True","``",".","*","If","``","True","``",",","returns","both","values","and","indices",".","Otherwise",",","returns","only","the","``","top-k","``","values",".","output_indices_dtype",":","const","<","str",">","(","Optional",",","default=","''","int32","''",")","*","It","can","only","be","set","when","``","return_indices","``","is","``","True","``",".","*","This","parameter","can","take","``","``","int32","''","``","or","``","``","uint16","''","``","as","values",".","Returns","--","--","--","-","tensor","<","\\","*","?",",","T",">","*","Values","of","top\/bottom","``","k","``","elements",".","tensor","<","\\","*","?",",","U",">","*","Only","returned","when","``","return_indices","=","True","``","*","Indices","of","the","top\/bottom","``","k","``","elements","along","axis",".","*","U","is","int32","or","uint16","determined","by","``","output_indices_dtype","``","(","int32","by","default",")",".","Attributes","--","--","--","--","--","T",":","fp16",",","fp32",",","int8",",","int16",",","int32",",","uint8",",","uint16","K",":","int8",",","int16",",","int32"]
code: def type_inference(self):
      if (
          not self.return_indices.val
          and self.output_indices_dtype is not None
      ):
          raise ValueError(
              'In iOS17 topk op, "output_indices_dtype" can only be set when "return_indices=True".'
          )
  
      if self.return_indices.val:
          if (
              self.output_indices_dtype.val
              not in self._ALLOWED_OUTPUT_INDICES_DTYPES
          ):
              raise ValueError(
                  f'"topk" op invalid output_indices_dtype: "{self.output_indices_dtype.val}". '
                  f"Valid options are: {self._ALLOWED_OUTPUT_INDICES_DTYPES}"
              )
  
          value_type, indices_type = super().type_inference()
          indices_type = types.tensor(
              types.string_to_builtin(self.output_indices_dtype.val),
              indices_type.get_shape(),
          )
          return value_type, indices_type
      else:
          return super().type_inference()
  
file_path: coremltools/coremltools/converters/mil/mil/ops/defs/iOS17/tensor_operation.py
imports: 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.tensor_operation import non_maximum_suppression
  from coremltools.converters.mil.mil.ops.defs.iOS16.tensor_operation import topk
  from coremltools.converters.mil.mil.ops.defs.iOS17 import _IOS17_TARGET
label_desc: Use image node_id 2 for calling the topk obj's underlying member method code with example usage: obj.type_inference() and returns: value_type,  indices_type, super