code: def safe_array(X, dtype=np.float64):
      """Checks if the X has the correct type, dtype, and is contiguous.
  
      Parameters
      ----------
      X : `pd.DataFrame` or `np.ndarray` or `crs_matrix`
          The input data.
  
      dtype : np.dtype object or string
          Expected dtype of each X element.
  
      Returns
      -------
      output : `np.ndarray` or `csr_matrix`
          The input with right type, dtype.
  
      """
      if isinstance(X, pd.DataFrame):
          X = X.values
  
      if isinstance(X, np.ndarray) and not X.flags["C_CONTIGUOUS"]:
          warn(
              "Copying array of size %s to create a C-contiguous "
              "version of it" % str(X.shape),
              RuntimeWarning,
          )
          X = np.ascontiguousarray(X)
  
      if X.dtype != dtype:
          warn(
              "Copying array of size %s to convert it in the right "
              "format" % str(X.shape),
              RuntimeWarning,
          )
          X = X.astype(dtype)
  
      return X
  
imports: import numpy
  import pandas
  from warnings import warn
label_desc: Use image node_id 1 for calling a global function with example usage: safe_array(X, dtype) and returns: X