code: def _get_output(
      output_type: Optional[str],
      input_type: Optional[str],
      out: DataFrame,
      dtype,
  ):
      if output_type == "input":
          if input_type == "array":
              output_type = "cupy"
          elif input_type == "df":
              output_type = "cudf"
  
      if output_type is None:
          output_type = "cupy"
  
      if output_type == "cudf":
          return out
      elif output_type == "cupy":
          return out.astype(dtype).to_cupy(na_value=np.nan)
      elif output_type == "numpy":
          return cp.asnumpy(out.to_cupy(na_value=np.nan, dtype=dtype))
      elif output_type == "pandas":
          return out.to_pandas()
      else:
          raise ValueError("Unsupported output type.")
  
imports: import warnings
  from typing import List, Optional, TypeVar
  import cuml.internals.logger
  from cudf import DataFrame, Series
  from cuml import Base
  from cuml.common.doc_utils import generate_docstring
  from cuml.common.exceptions import NotFittedError
  from cuml.internals.safe_imports import cpu_only_import, gpu_only_import, gpu_only_import_from
  from cuml.preprocessing import LabelEncoder
label_desc: Use image node_id 2 for calling a global function with example usage: _get_output(output_type, input_type, out, dtype) and returns: out, out, cp, out