code: def _ensure_args(api_name, G, directed, connection, return_labels):
      """
      Ensures the args passed in are usable for the API api_name and returns the
      args with proper defaults if not specified, or raises TypeError or
      ValueError if incorrectly specified.
      """
      G_type = type(G)
      # Check for Graph-type inputs and set defaults if unset
      if (G_type in [Graph]) or is_nx_graph_type(G_type):
          exc_value = "'%s' cannot be specified for a Graph-type input"
          if directed is not None:
              raise TypeError(exc_value % "directed")
          if return_labels is not None:
              raise TypeError(exc_value % "return_labels")
  
          directed = True
          return_labels = True
  
      # Check for non-Graph-type inputs and set defaults if unset
      else:
          directed = True if (directed is None) else directed
          return_labels = (
              True if (return_labels is None) else return_labels
          )
  
      # Handle connection type, based on API being called
      if api_name == "strongly_connected_components":
          if (connection is not None) and (connection != "strong"):
              raise TypeError(
                  "'connection' must be 'strong' for " f"{api_name}()"
              )
          connection = "strong"
      elif api_name == "weakly_connected_components":
          if (connection is not None) and (connection != "weak"):
              raise TypeError(
                  "'connection' must be 'weak' for " f"{api_name}()"
              )
          connection = "weak"
      else:
          raise RuntimeError(
              "invalid API name specified (internal): " f"{api_name}"
          )
  
      return (directed, connection, return_labels)
  
file_path: cugraph/python/cugraph/cugraph/components/connectivity.py
imports: from cugraph.utilities import df_score_to_dictionary, ensure_cugraph_obj, is_matrix_type, is_cp_matrix_type, is_nx_graph_type, cupy_package
  from cugraph.structure import Graph
  from cugraph.components import connectivity_wrapper
  import cudf
  from pylibcugraph import weakly_connected_components
  from pylibcugraph import ResourceHandle
label_desc: Use image node_id 1 for calling a global function with example usage: _ensure_args(api_name, G, directed, connection, return_labels) and returns: directed,  connection,  return_labels