code: def create_obj_from_csv(
      csv_file_name,
      obj_type,
      csv_has_weights=True,
      edgevals=False,
      directed=False,
  ):
      """
      Return an object based on obj_type populated with the contents of
      csv_file_name
      """
      if obj_type in [cugraph.Graph]:
          return generate_cugraph_graph_from_file(
              csv_file_name,
              directed=directed,
              edgevals=edgevals,
          )
      elif isinstance(obj_type, cugraph.Graph):
          return generate_cugraph_graph_from_file(
              csv_file_name,
              directed=directed,
              edgevals=edgevals,
          )
  
      elif obj_type in SCIPY_MATRIX_TYPES + CUPY_MATRIX_TYPES:
          # FIXME: assuming float32
          if csv_has_weights:
              (rows, cols, weights) = np.genfromtxt(
                  csv_file_name,
                  delimiter=" ",
                  dtype=np.float32,
                  unpack=True,
              )
          else:
              (rows, cols) = np.genfromtxt(
                  csv_file_name,
                  delimiter=" ",
                  dtype=np.float32,
                  unpack=True,
              )
  
          if (csv_has_weights is False) or (edgevals is False):
              # COO matrices must have a value array. Also if edgevals are to be
              # ignored (False), reset all weights to 1.
              weights = np.array([1] * len(rows))
  
          if obj_type in CUPY_MATRIX_TYPES:
              coo = cp_coo_matrix(
                  (
                      cp.asarray(weights),
                      (cp.asarray(rows), cp.asarray(cols)),
                  ),
                  dtype=np.float32,
              )
          else:
              coo = sp_coo_matrix(
                  (
                      weights,
                      (
                          np.array(rows, dtype=int),
                          np.array(cols, dtype=int),
                      ),
                  ),
              )
  
          if obj_type in [cp_csr_matrix, sp_csr_matrix]:
              return coo.tocsr(copy=False)
          elif obj_type in [cp_csc_matrix, sp_csc_matrix]:
              return coo.tocsc(copy=False)
          else:
              return coo
  
      elif obj_type in [nx.Graph, nx.DiGraph]:
          return generate_nx_graph_from_file(
              csv_file_name,
              directed=(obj_type is nx.DiGraph),
              edgevals=edgevals,
          )
  
      else:
          raise TypeError(f"unsupported type: {obj_type}")
  
imports: import os
  import pytest
  import pandas
  import networkx
  import numpy
  import cupy
  from cupyx.scipy.sparse import coo_matrix
  from cupyx.scipy.sparse import csr_matrix
  from cupyx.scipy.sparse import csc_matrix
  from scipy.sparse import coo_matrix
  from scipy.sparse import csr_matrix
  from scipy.sparse import csc_matrix
  from pathlib import Path
  import cudf
  import dask_cudf
  import cugraph
  from cugraph.dask.common.mg_utils import get_client
label_desc: Use image node_id 2 for calling a global function with example usage: create_obj_from_csv(csv_file_name, obj_type, csv_has_weights, edgevals, directed) and returns: generate_cugraph_graph_from_file, generate_cugraph_graph_from_file, coo, generate_nx_graph_from_file, coo, coo