class_docstr: A mapping from multi-dimensional indices to another set of multi-dimensional indices
  
  Parameters
  ----------
  initial_indices : List[Var]
      Variables representing the indices prior to remapping.
  final_indices : List[PrimExpr]
      Expressions defining the indices after remapping.
  inverse_index_map : Union[Callable, Optional[IndexMap]]
      The optional pre-defined inverse index map.
      When this is defined, IndexMap::Inverse will return the pre-defined inverse index map.
      Otherwise, the inverse index map will be computed on the fly.
      It is the user's responsibility to ensure the correctness of the pre-defined inverse
      index map.
class_docstr_tok: ["A","mapping","from","multi-dimensional","indices","to","another","set","of","multi-dimensional","indices","Parameters","--","--","--","--","--","initial_indices",":","List","[","Var","]","Variables","representing","the","indices","prior","to","remapping",".","final_indices",":","List","[","PrimExpr","]","Expressions","defining","the","indices","after","remapping",".","inverse_index_map",":","Union","[","Callable",",","Optional","[","IndexMap","]","]","The","optional","pre-defined","inverse","index","map",".","When","this","is","defined",",","IndexMap",":",":Inverse","will","return","the","pre-defined","inverse","index","map",".","Otherwise",",","the","inverse","index","map","will","be","computed","on","the","fly",".","It","is","the","user","'s","responsibility","to","ensure","the","correctness","of","the","pre-defined","inverse","index","map","."]
docstr: Create an index map from a function
  
  Parameters
  ----------
  mapping_function : Callable
  
      The function to map from source indices to target indices.
      The function should accept `tir.Var` parameters and return
      a either a `tir.PrimExpr`, or a list of `tir.PrimExpr`.
      Returning a `tir.PrimExpr` is equivalent to returning a
      list of length 1 containing that `tir.PrimExpr`.
  
  ndim: Optional[int]
  
      The dimensionality of the buffer to which this
      transformation should be applied.  If mapping_function uses
      variadic argument `*args`, `ndim` must be specified.  If
      mapping_function does not use variadic arguments, ndim is
      optional.
  
  inverse_index_map : Union[Callable, Optional[IndexMap]]
      The optional pre-defined inverse index map.
      When this is defined, IndexMap::Inverse will return the pre-defined inverse index map.
      Otherwise, the inverse index map will be computed on the fly.
      It is the user's responsibility to ensure the correctness of the pre-defined inverse
      index map.
  
  Returns
  -------
  index_map: IndexMap
  
      Returns an IndexMap representing the `mapping_function`.
docstr_tok: ["Create","an","index","map","from","a","function","Parameters","--","--","--","--","--","mapping_function",":","Callable","The","function","to","map","from","source","indices","to","target","indices",".","The","function","should","accept","`","tir.Var","`","parameters","and","return","a","either","a","`","tir.PrimExpr","`",",","or","a","list","of","`","tir.PrimExpr","`",".","Returning","a","`","tir.PrimExpr","`","is","equivalent","to","returning","a","list","of","length","1","containing","that","`","tir.PrimExpr","`",".","ndim",":","Optional","[","int","]","The","dimensionality","of","the","buffer","to","which","this","transformation","should","be","applied",".","If","mapping_function","uses","variadic","argument","`","*","args","`",",","`","ndim","`","must","be","specified",".","If","mapping_function","does","not","use","variadic","arguments",",","ndim","is","optional",".","inverse_index_map",":","Union","[","Callable",",","Optional","[","IndexMap","]","]","The","optional","pre-defined","inverse","index","map",".","When","this","is","defined",",","IndexMap",":",":Inverse","will","return","the","pre-defined","inverse","index","map",".","Otherwise",",","the","inverse","index","map","will","be","computed","on","the","fly",".","It","is","the","user","'s","responsibility","to","ensure","the","correctness","of","the","pre-defined","inverse","index","map",".","Returns","--","--","--","-","index_map",":","IndexMap","Returns","an","IndexMap","representing","the","`","mapping_function","`","."]
code: def from_func(
      mapping_function: Callable,
      ndim: Optional[int] = None,
      inverse_index_map: Union[Callable, Optional["IndexMap"]] = None,
      *,
      index_dtype: str = "int64",
  ):
      """Create an index map from a function
  
      Parameters
      ----------
      mapping_function : Callable
  
          The function to map from source indices to target indices.
          The function should accept `tir.Var` parameters and return
          a either a `tir.PrimExpr`, or a list of `tir.PrimExpr`.
          Returning a `tir.PrimExpr` is equivalent to returning a
          list of length 1 containing that `tir.PrimExpr`.
  
      ndim: Optional[int]
  
          The dimensionality of the buffer to which this
          transformation should be applied.  If mapping_function uses
          variadic argument `*args`, `ndim` must be specified.  If
          mapping_function does not use variadic arguments, ndim is
          optional.
  
      inverse_index_map : Union[Callable, Optional[IndexMap]]
          The optional pre-defined inverse index map.
          When this is defined, IndexMap::Inverse will return the pre-defined inverse index map.
          Otherwise, the inverse index map will be computed on the fly.
          It is the user's responsibility to ensure the correctness of the pre-defined inverse
          index map.
  
      Returns
      -------
      index_map: IndexMap
  
          Returns an IndexMap representing the `mapping_function`.
  
      """
      index_map, axis_separators = IndexMap.from_func_with_separators(
          mapping_function,
          ndim,
          inverse_index_map,
          index_dtype=index_dtype,
      )
      assert not axis_separators, (
          "The mapping_function provided to IndexMap.from_func "
          "may not return IndexMap.AXIS_SEPARATOR.  "
          "If required, please use IndexMap.from_func_with_separators instead."
      )
      return index_map
  
imports: import collections
  import inspect
  from typing import Callable, List, Mapping, Optional, Tuple, Union
  import tvm
  import tvm._ffi
  import tvm.runtime
  from tvm.ir import BaseFunc, Range
  from tvm.runtime import Object, Scriptable
  from ..runtime.ndarray import NDArray
  from .None import _ffi_api
  from .buffer import Buffer
  from .expr import PrimExpr, Var
label_desc: Use image node_id 2 for calling the IndexMap obj's underlying member method code with example usage: obj.from_func(mapping_function, ndim, inverse_index_map) and returns: index_map