code: def _pre_allow_complex_dtype(cast, complex_dtypes):
      def _allow_complex_dtype(target=None):
          """Allow complex type by calling the function twice.
  
          Assumes function do not support dtype.
  
          How it works?
          -------------
          Function is called twice if dtype is complex.
          Output is casted if not corresponding to expected dtype.
          """
  
          def _decorator(func):
              @functools.wraps(func)
              def _wrapped(*args, dtype=None, **kwargs):
                  out = func(*args, **kwargs)
                  if dtype in complex_dtypes:
                      out = out + 1j * func(*args, **kwargs)
  
                  if out.dtype != dtype:
                      return cast(out, dtype)
  
                  return out
  
              return _wrapped
  
          if target is None:
              return _decorator
  
          return _decorator(target)
  
      return _allow_complex_dtype
  
file_path: geomstats/geomstats/_backend/_dtype_utils.py
imports: import functools
  import inspect
  import types
  from geomstats._backend import _backend_config
label_desc: Use image node_id 13 for calling a global function with example usage: _pre_allow_complex_dtype(cast, complex_dtypes) and returns: _allow_complex_dtype, _decorator, _wrapped, _decorator, out, cast