code: def _check_and_cast_columns_with_other(
      source_col: ColumnBase,
      other: Union[ScalarLike, ColumnBase],
      inplace: bool,
  ) -> Tuple[ColumnBase, Union[ScalarLike, ColumnBase]]:
      # Returns type-casted `source_col` & `other` based on `inplace`.
      source_dtype = source_col.dtype
      if isinstance(source_dtype, CategoricalDtype):
          return _normalize_categorical(source_col, other)
  
      other_is_scalar = is_scalar(other)
      if other_is_scalar:
          if (isinstance(other, float) and not np.isnan(other)) and (
              source_dtype.type(other) != other
          ):
              raise TypeError(
                  f"Cannot safely cast non-equivalent "
                  f"{type(other).__name__} to {source_dtype.name}"
              )
  
          if cudf.utils.utils.is_na_like(other):
              return _normalize_categorical(
                  source_col, cudf.Scalar(other, dtype=source_dtype)
              )
  
      mixed_err = (
          "cudf does not support mixed types, please type-cast the column of "
          "dataframe/series and other to same dtypes."
      )
  
      if inplace:
          other = cudf.Scalar(other) if other_is_scalar else other
          if is_mixed_with_object_dtype(other, source_col):
              raise TypeError(mixed_err)
  
          if not _can_cast(other.dtype, source_dtype):
              warnings.warn(
                  f"Type-casting from {other.dtype} "
                  f"to {source_dtype}, there could be potential data loss"
              )
          return _normalize_categorical(
              source_col, other.astype(source_dtype)
          )
  
      if _is_non_decimal_numeric_dtype(source_dtype) and _can_cast(
          other, source_dtype
      ):
          common_dtype = source_dtype
      elif (
          isinstance(source_col, cudf.core.column.NumericalColumn)
          and other_is_scalar
          and _dtype_can_hold_element(source_dtype, other)
      ):
          common_dtype = source_dtype
      else:
          common_dtype = find_common_type(
              [
                  source_dtype,
                  np.min_scalar_type(other)
                  if other_is_scalar
                  else other.dtype,
              ]
          )
  
      if other_is_scalar:
          other = cudf.Scalar(other)
  
      if is_mixed_with_object_dtype(other, source_col) or (
          is_bool_dtype(source_dtype)
          and not is_bool_dtype(common_dtype)
      ):
          raise TypeError(mixed_err)
  
      other = other.astype(common_dtype)
  
      return _normalize_categorical(
          source_col.astype(common_dtype), other
      )
  
file_path: cudf/python/cudf/cudf/core/_internals/where.py
imports: import warnings
  from typing import Tuple, Union
  import numpy
  import cudf
  from cudf._typing import ScalarLike
  from cudf.api.types import _is_non_decimal_numeric_dtype, is_bool_dtype, is_scalar
  from cudf.core.column import ColumnBase
  from cudf.core.dtypes import CategoricalDtype
  from cudf.utils.dtypes import _can_cast, _dtype_can_hold_element, find_common_type, is_mixed_with_object_dtype
label_desc: Use image node_id 2 for calling a global function with example usage: _check_and_cast_columns_with_other(source_col, other, inplace) and returns: _normalize_categorical, _normalize_categorical, _normalize_categorical, _normalize_categorical