code: def run_async(func, *args, **kwargs):
      """
      If no loop is running on the current thread,
      this method calls func using a new event
      loop using asyncio.run.  If a loop is running, this
      method starts a new thread, and calls func on a new
      event loop in the new thread.
  
      Parameters
      ----------
      func : function
          The function that will be run.
      *args : args
          The arguments to the given function.
      **kwargs : kwargs
          The keyword arguments to the given function.
  
      Returns
      -------
      The output of the given function.
      """
      try:
          loop = asyncio.get_running_loop()
      except RuntimeError:
          loop = None
      if loop is not None:
          thread = RunAsyncioThread(func, args, kwargs)
          thread.start()
          thread.join()
          return thread.result
      else:
          return asyncio.run(func(*args, **kwargs))
  
imports: from cugraph_service_client.remote_graph_utils import import_optional, MissingModule
  import numpy
  from functools import wraps
  from collections.abc import Sequence
  import pickle
  import ucp
  import asyncio
  import threading
  from cugraph_service_client import defaults
  from cugraph_service_client.remote_graph import RemoteGraph
  from cugraph_service_client import extension_return_dtype_map
  from cugraph_service_client.types import ValueWrapper, GraphVertexEdgeID, UniformNeighborSampleResult
  from cugraph_service_client.cugraph_service_thrift import create_client
label_desc: Use image node_id 1 for calling a global function with example usage: run_async(func) and returns: thread, asyncio