code: def fromfunction(function, shape, *, dtype=float, **kwargs):
      def canonicalize_shape(shape, context="shape argument"):
          if isinstance(shape, int):
              return (shape,)
          elif isinstance(shape, list):
              return tuple(shape)
          elif isinstance(shape, tuple):
              return shape
          else:
              msg = f"{context} must be an int, list, or tuple, but got {type(shape)}."
              raise TypeError(msg)
  
      arr = ivy.zeros(shape, dtype=dtype)
      shape = canonicalize_shape(shape)
      # Iterate over the indices of the array
      for indices in ivy.ndindex(shape):
          f_indices = indices
          ivy.set_nest_at_index(
              arr,
              f_indices,
              ivy.asarray(function(*indices, **kwargs), dtype=dtype),
          )
      return arr
  
imports: import ivy
  from ivy.functional.frontends.jax.func_wrapper import to_ivy_arrays_and_back
  from ivy.functional.frontends.jax.numpy import promote_types_of_jax_inputs
  from ivy.utils.exceptions import IvyNotImplementedException
  from ivy.func_wrapper import with_unsupported_dtypes
label_desc: Use image node_id 12 for calling a global function with example usage: fromfunction(function, shape) and returns: arr, shape, tuple, shape