code: def _call_cupy(func, args, kwargs):
      """
      Calls cupy function with *args and **kwargs and
      does necessary data transfers.
  
      Args:
          func: A cupy function that needs to be called.
          args (tuple): Arguments.
          kwargs (dict): Keyword arguments.
  
      Returns:
          Result after calling func and performing data transfers.
      """
  
      _update_cupy_args(args, kwargs)
      cupy_args, cupy_kwargs = _convert_fallback_to_cupy(args, kwargs)
      cupy_res = func(*cupy_args, **cupy_kwargs)
  
      # If existing argument is being returned
      ext_res = _get_same_reference(
          cupy_res, cupy_args, cupy_kwargs, args, kwargs
      )
      if ext_res is not None:
          return ext_res
  
      if isinstance(cupy_res, cp.ndarray):
          if cupy_res.base is None:
              # Don't share memory
              fallback_res = _convert_cupy_to_fallback(cupy_res)
          else:
              # Share memory with one of the arguments
              base_arg = _get_same_reference(
                  cupy_res.base, cupy_args, cupy_kwargs, args, kwargs
              )
              fallback_res = _convert_cupy_to_fallback(cupy_res)
              fallback_res.base = base_arg
          return fallback_res
      return cupy_res
  
imports: import types
  import numpy
  import cupy
  from cupyx.fallback_mode import notification
label_desc: Use image node_id 9 for calling a global function with example usage: _call_cupy(func, args, kwargs) and returns: cupy_res, ext_res, fallback_res