code: def test_function_backend_computation(
      fw, test_flags, all_as_kwargs_np, input_dtypes, on_device, fn_name
  ):
      # split the arguments into their positional and keyword components
      args_np, kwargs_np = kwargs_to_args_n_kwargs(
          num_positional_args=test_flags.num_positional_args,
          kwargs=all_as_kwargs_np,
      )
  
      # Extract all arrays from the arguments and keyword arguments
      (
          arg_np_arrays,
          arrays_args_indices,
          n_args_arrays,
      ) = _get_nested_np_arrays(args_np)
      (
          kwarg_np_arrays,
          arrays_kwargs_indices,
          n_kwargs_arrays,
      ) = _get_nested_np_arrays(kwargs_np)
  
      # Make all array-specific test flags and dtypes equal in length
      total_num_arrays = n_args_arrays + n_kwargs_arrays
      if len(input_dtypes) < total_num_arrays:
          input_dtypes = [
              input_dtypes[0] for _ in range(total_num_arrays)
          ]
      if len(test_flags.as_variable) < total_num_arrays:
          test_flags.as_variable = [
              test_flags.as_variable[0] for _ in range(total_num_arrays)
          ]
      if len(test_flags.native_arrays) < total_num_arrays:
          test_flags.native_arrays = [
              test_flags.native_arrays[0]
              for _ in range(total_num_arrays)
          ]
      if len(test_flags.container) < total_num_arrays:
          test_flags.container = [
              test_flags.container[0] for _ in range(total_num_arrays)
          ]
  
      if test_flags.test_cython_wrapper:
          ivy.set_cython_wrappers_mode(True)
      else:
          ivy.set_cython_wrappers_mode(False)
  
      with BackendHandler.update_backend(fw) as ivy_backend:
          # Update variable flags to be compatible with float dtype and with_out args
          test_flags.as_variable = [
              v
              if ivy_backend.is_float_dtype(d)
              and not test_flags.with_out
              else False
              for v, d in zip(test_flags.as_variable, input_dtypes)
          ]
  
      # update instance_method flag to only be considered if the
      # first term is either an ivy.Array or ivy.Container
      instance_method = test_flags.instance_method and (
          not test_flags.native_arrays[0] or test_flags.container[0]
      )
  
      args, kwargs = create_args_kwargs(
          backend=fw,
          args_np=args_np,
          arg_np_vals=arg_np_arrays,
          args_idxs=arrays_args_indices,
          kwargs_np=kwargs_np,
          kwarg_np_vals=kwarg_np_arrays,
          kwargs_idxs=arrays_kwargs_indices,
          input_dtypes=input_dtypes,
          test_flags=test_flags,
          on_device=on_device,
      )
  
      # If function doesn't have an out argument but an out argument is given
      # or a test with out flag is True
  
      if (
          "out" in kwargs or test_flags.with_out
      ) and "out" not in inspect.signature(
          getattr(ivy, fn_name)
      ).parameters:
          raise RuntimeError(
              f"Function {fn_name} does not have an out parameter"
          )
  
      # Run either as an instance method or from the API directly
      with BackendHandler.update_backend(fw) as ivy_backend:
          instance = None
          if instance_method:
              array_or_container_mask = [
                  (not native_flag) or container_flag
                  for native_flag, container_flag in zip(
                      test_flags.native_arrays, test_flags.container
                  )
              ]
  
              # Boolean mask for args and kwargs True if an entry's
              # test Array flag is True or test Container flag is true
              args_instance_mask = array_or_container_mask[
                  : test_flags.num_positional_args
              ]
              kwargs_instance_mask = array_or_container_mask[
                  test_flags.num_positional_args :
              ]
  
              if any(args_instance_mask):
                  instance, args = _find_instance_in_args(
                      fw, args, arrays_args_indices, args_instance_mask
                  )
              else:
                  instance, kwargs = _find_instance_in_args(
                      fw,
                      kwargs,
                      arrays_kwargs_indices,
                      kwargs_instance_mask,
                  )
  
              if test_flags.test_trace:
  
                  def target_fn(instance, *args, **kwargs):
                      return instance.__getattribute__(fn_name)(
                          *args, **kwargs
                      )
  
                  args = [instance, *args]
              else:
                  target_fn = instance.__getattribute__(fn_name)
          else:
              target_fn = ivy_backend.__dict__[fn_name]
  
          # Make copy of arguments for functions that might use inplace update by default
          copy_kwargs = copy.deepcopy(kwargs)
          copy_args = copy.deepcopy(args)
  
          (
              ret_from_target,
              ret_np_flat_from_target,
          ) = get_ret_and_flattened_np_array(
              fw,
              target_fn,
              *copy_args,
              test_trace=test_flags.test_trace,
              **copy_kwargs,
          )
  
          assert ivy_backend.nested_map(
              lambda x: ivy_backend.is_ivy_array(x)
              if ivy_backend.is_array(x)
              else True,
              ret_from_target,
          ), f"Ivy function returned non-ivy arrays: {ret_from_target}"
  
          # Assert indices of return if the indices of the out array provided
          if test_flags.with_out and not test_flags.test_trace:
              test_ret = (
                  ret_from_target[
                      getattr(
                          ivy_backend.__dict__[fn_name], "out_index"
                      )
                  ]
                  if hasattr(ivy_backend.__dict__[fn_name], "out_index")
                  else ret_from_target
              )
              out = ivy_backend.nested_map(
                  ivy_backend.zeros_like,
                  test_ret,
                  to_mutable=True,
                  include_derived=True,
              )
              if instance_method:
                  (
                      ret_from_target,
                      ret_np_flat_from_target,
                  ) = get_ret_and_flattened_np_array(
                      fw,
                      instance.__getattribute__(fn_name),
                      *args,
                      **kwargs,
                      out=out,
                  )
              else:
                  (
                      ret_from_target,
                      ret_np_flat_from_target,
                  ) = get_ret_and_flattened_np_array(
                      fw,
                      ivy_backend.__dict__[fn_name],
                      *args,
                      **kwargs,
                      out=out,
                  )
              test_ret = (
                  ret_from_target[
                      getattr(
                          ivy_backend.__dict__[fn_name], "out_index"
                      )
                  ]
                  if hasattr(ivy_backend.__dict__[fn_name], "out_index")
                  else ret_from_target
              )
              assert not ivy_backend.nested_any(
                  ivy_backend.nested_multi_map(
                      lambda x, _: x[0] is x[1], [test_ret, out]
                  ),
                  lambda x: not x,
              ), "the array in out argument does not contain same value as the returned"
              if (
                  not max(test_flags.container)
                  and ivy_backend.native_inplace_support
              ):
                  # these backends do not always support native inplace updates
                  assert not ivy_backend.nested_any(
                      ivy_backend.nested_multi_map(
                          lambda x, _: x[0].data is x[1].data,
                          [test_ret, out],
                      ),
                      lambda x: not x,
                  ), (
                      "the array in out argument does not contain same value as the"
                      " returned"
                  )
          if test_flags.with_copy:
              array_fn = ivy_backend.is_array
              if "copy" in list(
                  inspect.signature(target_fn).parameters.keys()
              ):
                  kwargs["copy"] = True
              if instance_method:
                  first_array = instance
              else:
                  first_array = (
                      ivy_backend.func_wrapper._get_first_array(
                          *args, array_fn=array_fn, **kwargs
                      )
                  )
              ret_, ret_np_flat_ = get_ret_and_flattened_np_array(
                  fw,
                  target_fn,
                  *args,
                  test_trace=test_flags.test_trace,
                  precision_mode=test_flags.precision_mode,
                  **kwargs,
              )
              assert not np.may_share_memory(first_array, ret_)
  
      ret_device = None
      if isinstance(
          ret_from_target, ivy_backend.Array
      ):  # TODO use str for now
          ret_device = ivy_backend.dev(ret_from_target)
      return (
          ret_from_target,
          ret_np_flat_from_target,
          ret_device,
          args_np,
          arg_np_arrays,
          arrays_args_indices,
          kwargs_np,
          arrays_kwargs_indices,
          kwarg_np_arrays,
          test_flags,
          input_dtypes,
      )
  
imports: import copy
  import time
  from typing import Union, List, Optional
  import numpy
  import types
  import importlib
  import inspect
  from collections import OrderedDict
  from .globals import mod_backend
  from .pipeline_helper import BackendHandler, BackendHandlerMode, get_frontend_config
  import ivy
  from ivy_tests.test_ivy.helpers.test_parameter_flags import FunctionTestFlags
  import ivy_tests.test_ivy.helpers.test_parameter_flags
  import ivy_tests.test_ivy.helpers.globals
  from ivy.functional.ivy.data_type import _get_function_list, _get_functions_from_string
  from ivy_tests.test_ivy.test_frontends import NativeClass
  from ivy_tests.test_ivy.helpers.structs import FrontendMethodData
  from ivy_tests.test_ivy.helpers.testing_helpers import _create_transpile_report
  from .assertions import value_test, assert_same_type, check_unsupported_dtype
label_desc: Use image node_id 4 for calling a global function with example usage: test_function_backend_computation(fw, test_flags, all_as_kwargs_np, input_dtypes, on_device, fn_name) and returns: ret_from_target,  ret_np_flat_from_target,  ret_device,  args_np,  arg_np_arrays,  arrays_args_indices,  kwargs_np,  arrays_kwargs_indices,  kwarg_np_arrays,  test_flags,  input_dtypes, instance