code: def traced_if_required(
      backend: str, fn, test_trace=False, args=None, kwargs=None
  ):
      with BackendHandler.update_backend(backend) as ivy_backend:
          if test_trace:
              try:
                  if (
                      t_globals.CURRENT_RUNNING_TEST.fn_name
                      in t_globals.CURRENT_TRACED_DATA
                      and backend
                      not in t_globals.CURRENT_TRACED_DATA[
                          t_globals.CURRENT_RUNNING_TEST.fn_name
                      ]
                  ):
                      t_globals.CURRENT_TRACED_DATA[
                          t_globals.CURRENT_RUNNING_TEST.fn_name
                      ][backend] = ivy_backend.trace_graph(
                          fn, args=args, kwargs=kwargs
                      )
                  elif (
                      t_globals.CURRENT_RUNNING_TEST.fn_name
                      not in t_globals.CURRENT_TRACED_DATA
                  ):
                      t_globals.CURRENT_TRACED_DATA[
                          t_globals.CURRENT_RUNNING_TEST.fn_name
                      ] = {}
                      t_globals.CURRENT_TRACED_DATA[
                          t_globals.CURRENT_RUNNING_TEST.fn_name
                      ][backend] = ivy_backend.trace_graph(
                          fn, args=args, kwargs=kwargs
                      )
                  fn = t_globals.CURRENT_TRACED_DATA[
                      t_globals.CURRENT_RUNNING_TEST.fn_name
                  ][backend]
              except Exception:
                  import logging
  
                  logging.warning(
                      "API key is invalid, test_trace is skipped."
                  )
      return fn
  
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 1 for calling a global function with example usage: traced_if_required(backend, fn, test_trace, args, kwargs) and returns: fn