code: def result_type(
      *args: Any, return_weak_type_flag: bool = False
  ) -> DType | tuple[DType, bool]:
      """Convenience function to apply JAX argument dtype promotion.
  
      Args:
        return_weak_type_flag : if True, then return a ``(dtype, weak_type)`` tuple.
          If False, just return `dtype`
  
      Returns:
        dtype or (dtype, weak_type) depending on the value of the ``return_weak_type`` argument.
      """
      if len(args) == 0:
          raise ValueError("at least one array or dtype is required")
      dtype: DType | ExtendedDType
      dtype, weak_type = _lattice_result_type(
          *(float_ if arg is None else arg for arg in args)
      )
      if weak_type:
          dtype = canonicalize_dtype(
              _default_types[
                  "f" if dtype in _custom_float_dtypes else dtype.kind
              ]
          )
      else:
          dtype = canonicalize_dtype(dtype, allow_extended_dtype=True)
      # TODO(jakevdp): fix return type annotation and remove this ignore.
      return (dtype, weak_type) if return_weak_type_flag else dtype
  
imports: from __future__ import annotations
  import abc
  import builtins
  import functools
  from typing import cast, overload, Any, Literal, Union
  import warnings
  import ml_dtypes
  import numpy
  from jax._src import config
  from jax._src.typing import DType, DTypeLike
  from jax._src.util import set_module
  from jax._src import traceback_util
label_desc: Use image node_id 28 for calling a global function with example usage: result_type() and returns: unknown