code: def test_method(
      *,
      init_input_dtypes: Optional[List[ivy.Dtype]] = None,
      method_input_dtypes: Optional[List[ivy.Dtype]] = None,
      init_all_as_kwargs_np: Optional[dict] = None,
      method_all_as_kwargs_np: Optional[dict] = None,
      init_flags: pf.MethodTestFlags,
      method_flags: pf.MethodTestFlags,
      class_name: str,
      method_name: str = "__call__",
      init_with_v: bool = False,
      method_with_v: bool = False,
      rtol_: Optional[float] = None,
      atol_: float = 1e-06,
      tolerance_dict=None,
      test_values: Union[bool, str] = True,
      test_gradients: bool = False,
      xs_grad_idxs=None,
      ret_grad_idxs=None,
      test_trace: bool = False,
      backend_to_test: str,
      ground_truth_backend: str,
      on_device: str,
      return_flat_np_arrays: bool = False,
  ):
      """Test a class-method that consumes (or returns) arrays for the current
      backend by comparing the result with numpy.
  
      Parameters
      ----------
      init_input_dtypes
          data types of the input arguments to the constructor in order.
      init_as_variable_flags
          dictates whether the corresponding input argument passed to the constructor
          should be treated as an ivy.Array.
      init_num_positional_args
          number of input arguments that must be passed as positional arguments to the
          constructor.
      init_native_array_flags
          dictates whether the corresponding input argument passed to the constructor
          should be treated as a native array.
      init_all_as_kwargs_np:
          input arguments to the constructor as keyword arguments.
      method_input_dtypes
          data types of the input arguments to the method in order.
      method_as_variable_flags
          dictates whether the corresponding input argument passed to the method should
          be treated as an ivy.Array.
      method_num_positional_args
          number of input arguments that must be passed as positional arguments to the
          method.
      method_native_array_flags
          dictates whether the corresponding input argument passed to the method should
          be treated as a native array.
      method_container_flags
          dictates whether the corresponding input argument passed to the method should
          be treated as an ivy Container.
      method_all_as_kwargs_np:
          input arguments to the method as keyword arguments.
      class_name
          name of the class to test.
      method_name
          name of the method to test.
      init_with_v
          if the class being tested is an ivy.Module, then setting this flag as True will
          call the constructor with the variables v passed explicitly.
      method_with_v
          if the class being tested is an ivy.Module, then setting this flag as True will
          call the method with the variables v passed explicitly.
      rtol_
          relative tolerance value.
      atol_
          absolute tolerance value.
      test_values
          can be a bool or a string to indicate whether correctness of values should be
          tested. If the value is `with_v`, shapes are tested but not values.
      test_gradients
          if True, test for the correctness of gradients.
      xs_grad_idxs
          Indices of the input arrays to compute gradients with respect to. If None,
          gradients are returned with respect to all input arrays. (Default value = None)
      ret_grad_idxs
          Indices of the returned arrays for which to return computed gradients. If None,
          gradients are returned for all returned arrays. (Default value = None)
      test_trace
          If True, test for the correctness of tracing.
      ground_truth_backend
          Ground Truth Backend to compare the result-values.
      device_
          The device on which to create arrays.
      return_flat_np_arrays
          If test_values is False, this flag dictates whether the original returns are
          returned, or whether the flattened numpy arrays are returned.
  
      Returns
      -------
      ret
          optional, return value from the function
      ret_gt
          optional, return value from the Ground Truth function
      """
      # check to see if multiprocessing is to be used
  
      if mod_backend[backend_to_test]:
          # yep, multiprocessing
          proc, input_queue, output_queue = mod_backend[backend_to_test]
          input_queue.put(
              (
                  "method_backend_computation",
                  init_input_dtypes,
                  init_flags,
                  backend_to_test,
                  init_all_as_kwargs_np,
                  on_device,
                  method_input_dtypes,
                  method_flags,
                  method_all_as_kwargs_np,
                  class_name,
                  method_name,
                  init_with_v,
                  test_trace,
                  method_with_v,
              )
          )
          (
              ret,
              ret_np_flat,
              ret_device,
              org_con_data,
              args_np_method,
              met_arg_np_vals,
              met_args_idxs,
              kwargs_np_method,
              met_kwarg_np_vals,
              met_kwargs_idxs,
              v_np,
              fw_list,
          ) = output_queue.get()
      else:
          (
              ret,
              ret_np_flat,
              ret_device,
              org_con_data,
              args_np_method,
              met_arg_np_vals,
              met_args_idxs,
              kwargs_np_method,
              met_kwarg_np_vals,
              met_kwargs_idxs,
              v_np,
              fw_list,
          ) = test_method_backend_computation(
              init_input_dtypes,
              init_flags,
              backend_to_test,
              init_all_as_kwargs_np,
              on_device,
              method_input_dtypes,
              method_flags,
              method_all_as_kwargs_np,
              class_name,
              method_name,
              init_with_v,
              test_trace,
              method_with_v,
          )
  
      # Compute the return with a Ground Truth backend
      if mod_backend[ground_truth_backend]:
          # yep, multiprocessing
          proc, input_queue, output_queue = mod_backend[
              ground_truth_backend
          ]
          input_queue.put(
              (
                  "method_ground_truth_computation",
                  ground_truth_backend,
                  on_device,
                  org_con_data,
                  args_np_method,
                  met_arg_np_vals,
                  met_args_idxs,
                  kwargs_np_method,
                  met_kwarg_np_vals,
                  met_kwargs_idxs,
                  method_input_dtypes,
                  method_flags,
                  class_name,
                  method_name,
                  test_trace,
                  v_np,
              )
          )
          (
              ret_from_gt,
              ret_np_from_gt_flat,
              ret_from_gt_device,
              fw_list2,
          ) = output_queue.get()
      else:
          (
              ret_from_gt,
              ret_np_from_gt_flat,
              ret_from_gt_device,
              fw_list2,
          ) = test_method_ground_truth_computation(
              ground_truth_backend,
              on_device,
              org_con_data,
              args_np_method,
              met_arg_np_vals,
              met_args_idxs,
              kwargs_np_method,
              met_kwarg_np_vals,
              met_kwargs_idxs,
              method_input_dtypes,
              method_flags,
              class_name,
              method_name,
              test_trace,
              v_np,
          )
  
      for k, v in fw_list2.items():
          if k not in fw_list:
              fw_list[k] = []
          fw_list[k].extend(v)
  
      # gradient test
      # TODO enable gradient testing
      # if (
      #     test_gradients
      #     and not backend_to_test == "numpy"
      #     and "bool" not in method_input_dtypes
      #     and not any(ivy.is_complex_dtype(d) for d in method_input_dtypes)
      # ):
      #     if fw in fw_list:
      #         if ivy.nested_argwhere(
      #             method_all_as_kwargs_np,
      #             lambda x: x.dtype in fw_list[fw] if isinstance(x, np.ndarray)
      #               else None,
      #         ):
      #             pass
      #         else:
      #             gradient_test(
      #                 fn=[
      #                     ins.__getattribute__(method_name),
      #                     ins_gt.__getattribute__(method_name),
      #                 ],
      #                 all_as_kwargs_np=method_all_as_kwargs_np,
      #                 args_np=args_np_method,
      #                 kwargs_np=kwargs_np_method,
      #                 input_dtypes=method_input_dtypes,
      #                 test_flags=method_flags,
      #                 test_trace=test_trace,
      #                 rtol_=rtol_,
      #                 atol_=atol_,
      #                 xs_grad_idxs=xs_grad_idxs,
      #                 ret_grad_idxs=ret_grad_idxs,
      #                 ground_truth_backend=ground_truth_backend,
      #                 on_device=on_device,
      #             )
  
      #     else:
      #         gradient_test(
      #             fn=[
      #                 ins.__getattribute__(method_name),
      #                 ins_gt.__getattribute__(method_name),
      #             ],
      #             all_as_kwargs_np=method_all_as_kwargs_np,
      #             args_np=args_np_method,
      #             kwargs_np=kwargs_np_method,
      #             input_dtypes=method_input_dtypes,
      #             test_flags=method_flags,
      #             test_trace=test_trace,
      #             rtol_=rtol_,
      #             atol_=atol_,
      #             xs_grad_idxs=xs_grad_idxs,
      #             ret_grad_idxs=ret_grad_idxs,
      #             ground_truth_backend=ground_truth_backend,
      #             on_device=on_device,
      #         )
  
      assert ret_device == ret_from_gt_device, (
          f"ground truth backend ({ground_truth_backend}) returned array on"
          f" device {ret_from_gt_device} but target backend ({backend_to_test})"
          f" returned array on device {ret_device}"
      )
      if ret_device is not None:
          assert ret_device == on_device, (
              f"device is set to {on_device}, but ground truth produced array on"
              f" {ret_device}"
          )
  
      # assuming value test will be handled manually in the test function
      if not test_values:
          if return_flat_np_arrays:
              return ret_np_flat, ret_np_from_gt_flat
          return ret, ret_from_gt
      # value test
  
      if isinstance(rtol_, dict):
          rtol_ = _get_framework_rtol(rtol_, backend_to_test)
      if isinstance(atol_, dict):
          atol_ = _get_framework_atol(atol_, backend_to_test)
  
      value_test(
          backend=backend_to_test,
          ground_truth_backend=ground_truth_backend,
          ret_np_flat=ret_np_flat,
          ret_np_from_gt_flat=ret_np_from_gt_flat,
          rtol=rtol_,
          atol=atol_,
          specific_tolerance_dict=tolerance_dict,
      )
  
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 15 for calling a global function with example usage: test_method() and returns: ret,  ret_from_gt, ret_np_flat,  ret_np_from_gt_flat