code: def to_numeric(arg, errors="raise", downcast=None):
      """
      Convert argument into numerical types.
  
      Parameters
      ----------
      arg : column-convertible
          The object to convert to numeric types
      errors : {'raise', 'ignore', 'coerce'}, defaults 'raise'
          Policy to handle errors during parsing.
  
          * 'raise' will notify user all errors encountered.
          * 'ignore' will skip error and returns ``arg``.
          * 'coerce' will leave invalid values as nulls.
      downcast : {'integer', 'signed', 'unsigned', 'float'}, defaults None
          If set, will try to down-convert the datatype of the
          parsed results to smallest possible type. For each `downcast`
          type, this method will determine the smallest possible
          dtype from the following sets:
  
          * {'integer', 'signed'}: all integer types greater or equal to
            `np.int8`
          * {'unsigned'}: all unsigned types greater or equal to `np.uint8`
          * {'float'}: all floating types greater or equal to `np.float32`
  
          Note that downcast behavior is decoupled from parsing. Errors
          encountered during downcast is raised regardless of ``errors``
          parameter.
  
      Returns
      -------
      Series or ndarray
          Depending on the input, if series is passed in, series is returned,
          otherwise ndarray
  
      Notes
      -----
      An important difference from pandas is that this function does not accept
      mixed numeric/non-numeric type sequences. For example ``[1, 'a']``.
      A ``TypeError`` will be raised when such input is received, regardless of
      ``errors`` parameter.
  
      Examples
      --------
      >>> s = cudf.Series(['1', '2.0', '3e3'])
      >>> cudf.to_numeric(s)
      0       1.0
      1       2.0
      2    3000.0
      dtype: float64
      >>> cudf.to_numeric(s, downcast='float')
      0       1.0
      1       2.0
      2    3000.0
      dtype: float32
      >>> cudf.to_numeric(s, downcast='signed')
      0       1
      1       2
      2    3000
      dtype: int16
      >>> s = cudf.Series(['apple', '1.0', '3e3'])
      >>> cudf.to_numeric(s, errors='ignore')
      0    apple
      1      1.0
      2      3e3
      dtype: object
      >>> cudf.to_numeric(s, errors='coerce')
      0      <NA>
      1       1.0
      2    3000.0
      dtype: float64
      """
  
      if errors not in {"raise", "ignore", "coerce"}:
          raise ValueError("invalid error value specified")
  
      if downcast not in {
          None,
          "integer",
          "signed",
          "unsigned",
          "float",
      }:
          raise ValueError("invalid downcasting method provided")
  
      if not can_convert_to_column(arg) or (
          hasattr(arg, "ndim") and arg.ndim > 1
      ):
          raise ValueError("arg must be column convertible")
  
      col = as_column(arg)
      dtype = col.dtype
  
      if is_datetime_dtype(dtype) or is_timedelta_dtype(dtype):
          col = col.as_numerical_column(cudf.dtype("int64"))
      elif isinstance(dtype, CategoricalDtype):
          cat_dtype = col.dtype.type
          if _is_non_decimal_numeric_dtype(cat_dtype):
              col = col.as_numerical_column(cat_dtype)
          else:
              try:
                  col = _convert_str_col(
                      col._get_decategorized_column(), errors, downcast
                  )
              except ValueError as e:
                  if errors == "ignore":
                      return arg
                  else:
                      raise e
      elif is_string_dtype(dtype):
          try:
              col = _convert_str_col(col, errors, downcast)
          except ValueError as e:
              if errors == "ignore":
                  return arg
              else:
                  raise e
      elif isinstance(dtype, (cudf.ListDtype, cudf.StructDtype)):
          raise ValueError("Input does not support nested datatypes")
      elif _is_non_decimal_numeric_dtype(dtype):
          pass
      else:
          raise ValueError("Unrecognized datatype")
  
      # str->float conversion may require lower precision
      if col.dtype == cudf.dtype("f"):
          col = col.as_numerical_column("d")
  
      if downcast:
          if downcast == "float":
              # we support only float32 & float64
              type_set = [
                  cudf.dtype(np.float32).char,
                  cudf.dtype(np.float64).char,
              ]
          elif downcast in ("integer", "signed"):
              type_set = list(np.typecodes["Integer"])
          elif downcast == "unsigned":
              type_set = list(np.typecodes["UnsignedInteger"])
  
          for t in type_set:
              downcast_dtype = cudf.dtype(t)
              if downcast_dtype.itemsize <= col.dtype.itemsize:
                  if col.can_cast_safely(downcast_dtype):
                      col = libcudf.unary.cast(col, downcast_dtype)
                      break
  
      if isinstance(arg, (cudf.Series, pd.Series)):
          return cudf.Series(col, index=arg.index, name=arg.name)
      else:
          if col.has_nulls():
              # To match pandas, always return a floating type filled with nan.
              col = col.astype(float).fillna(np.nan)
          return col.values
  
file_path: cudf/python/cudf/cudf/core/tools/numeric.py
imports: import warnings
  import numpy
  import pandas
  import cudf
  from cudf import _lib
  from cudf._lib import strings
  from cudf.api.types import _is_non_decimal_numeric_dtype, is_datetime_dtype, is_string_dtype, is_timedelta_dtype
  from cudf.core.column import as_column
  from cudf.core.dtypes import CategoricalDtype
  from cudf.utils.dtypes import can_convert_to_column
label_desc: Use image node_id 1 for calling a global function with example usage: to_numeric(arg, errors, downcast) and returns: cudf, col, arg, arg