code: def _pre_cast_fout_to_input_dtype(cast, is_floating):
      def _cast_fout_to_input_dtype(target=None):
          """Cast out func if float and not accordingly to input.
  
          It is required e.g. for scipy when result is innacurate.
  
          How it works?
          -------------
          Function is called normally. If output is float, then it
          checks if is of expected dtype (input dtype). If not, cast is performed.
  
          The difference to `_cast_out_from_dtype` is that output is expected to
          have same type as input.
          """
  
          def _decorator(func):
              @functools.wraps(func)
              def _wrapped(x, *args, **kwargs):
                  out = func(x, *args, **kwargs)
                  if is_floating(out) and out.dtype != x.dtype:
                      return cast(out, x.dtype)
                  return out
  
              return _wrapped
  
          if target is None:
              return _decorator
  
          return _decorator(target)
  
      return _cast_fout_to_input_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 11 for calling a global function with example usage: _pre_cast_fout_to_input_dtype(cast, is_floating) and returns: _cast_fout_to_input_dtype, _decorator, _wrapped, _decorator, out, cast