code: def get_legacy_backend_wrapper(backend_name):
      """
      Returns a callable that wraps an algo function with either the default
      dispatcher (which dispatches based on input graph type), or the "testing"
      dispatcher (which autoconverts and unconditionally dispatches).
      This is only supported for NetworkX <3.2
      """
      backends.plugin_name = "cugraph"
      orig_dispatch = backends._dispatch
      testing_dispatch = backends.test_override_dispatch
  
      if backend_name == "cugraph":
          dispatch = testing_dispatch
      else:
          dispatch = orig_dispatch
  
      def wrap_callable_for_dispatch(
          func, exhaust_returned_iterator=False
      ):
          # Networkx <3.2 registers functions when the dispatch decorator is
          # applied (called) and errors if re-registered, so clear bookkeeping to
          # allow it to be called repeatedly.
          backends._registered_algorithms = {}
          actual_func = dispatch(
              func
          )  # returns the func the dispatcher picks
  
          def wrapper(*args, **kwargs):
              retval = actual_func(*args, **kwargs)
              if exhaust_returned_iterator:
                  retval = list(retval)
              return retval
  
          return wrapper
  
      return wrap_callable_for_dispatch
  
imports: import random
  import networkx
  import pandas
  import pytest
  from cugraph import datasets
  import nx_cugraph
label_desc: Use image node_id 5 for calling a global function with example usage: get_legacy_backend_wrapper(backend_name) and returns: wrap_callable_for_dispatch, wrapper, retval