code: def _to_directed_graph(
      G,
      edge_attr: AttrKey | None = None,
      edge_default: EdgeValue | None = 1,
      edge_dtype: Dtype | None = None,
  ) -> nxcg.DiGraph:
      """Ensure that input type is a nx_cugraph DiGraph, and convert if necessary.
  
      Undirected graphs will be converted to directed.
      This is an internal utility function and may change or be removed.
      """
      if isinstance(G, nxcg.DiGraph):
          return G
      if isinstance(G, nxcg.Graph):
          return G.to_directed()
      if isinstance(G, nx.Graph):
          return from_networkx(
              G,
              {edge_attr: edge_default}
              if edge_attr is not None
              else None,
              edge_dtype,
              as_directed=True,
          )
      # TODO: handle cugraph.Graph
      raise TypeError
  
file_path: cugraph/python/nx-cugraph/nx_cugraph/convert.py
imports: from __future__ import annotations
  import itertools
  import operator
  from collections import Counter
  from collections.abc import Mapping
  from typing import TYPE_CHECKING
  import cupy
  import networkx
  import numpy
  import nx_cugraph
  from .utils import index_dtype
label_desc: Use image node_id 6 for calling a global function with example usage: _to_directed_graph(G, edge_attr, edge_default, edge_dtype) and returns: G, G, from_networkx