code: def _match_join_keys(
      lcol: ColumnBase, rcol: ColumnBase, how: str
  ) -> Tuple[ColumnBase, ColumnBase]:
      # Casts lcol and rcol to a common dtype for use as join keys. If no casting
      # is necessary, they are returned as is.
  
      common_type = None
  
      # cast the keys lcol and rcol to a common dtype
      ltype = lcol.dtype
      rtype = rcol.dtype
  
      # if either side is categorical, different logic
      left_is_categorical = isinstance(ltype, CategoricalDtype)
      right_is_categorical = isinstance(rtype, CategoricalDtype)
      if left_is_categorical and right_is_categorical:
          return _match_categorical_dtypes_both(
              cast(CategoricalColumn, lcol),
              cast(CategoricalColumn, rcol),
              how,
          )
      elif left_is_categorical or right_is_categorical:
          if left_is_categorical:
              if how in {"left", "leftsemi", "leftanti"}:
                  return lcol, rcol.astype(ltype)
              common_type = ltype.categories.dtype
          else:
              common_type = rtype.categories.dtype
          common_type = cudf.utils.dtypes._dtype_pandas_compatible(
              common_type
          )
          return lcol.astype(common_type), rcol.astype(common_type)
  
      if is_dtype_equal(ltype, rtype):
          return lcol, rcol
  
      if is_decimal_dtype(ltype) or is_decimal_dtype(rtype):
          raise TypeError(
              "Decimal columns can only be merged with decimal columns "
              "of the same precision and scale"
          )
  
      if (
          np.issubdtype(ltype, np.number)
          and np.issubdtype(rtype, np.number)
          and not (
              np.issubdtype(ltype, np.timedelta64)
              or np.issubdtype(rtype, np.timedelta64)
          )
      ):
          common_type = (
              max(ltype, rtype)
              if ltype.kind == rtype.kind
              else np.find_common_type([], (ltype, rtype))
          )
      elif (
          np.issubdtype(ltype, np.datetime64)
          and np.issubdtype(rtype, np.datetime64)
      ) or (
          np.issubdtype(ltype, np.timedelta64)
          and np.issubdtype(rtype, np.timedelta64)
      ):
          common_type = max(ltype, rtype)
      elif (
          np.issubdtype(ltype, np.datetime64)
          or np.issubdtype(ltype, np.timedelta64)
      ) and not rcol.fillna(0).can_cast_safely(ltype):
          raise TypeError(
              f"Cannot join between {ltype} and {rtype}, please type-cast both "
              "columns to the same type."
          )
      elif (
          np.issubdtype(rtype, np.datetime64)
          or np.issubdtype(rtype, np.timedelta64)
      ) and not lcol.fillna(0).can_cast_safely(rtype):
          raise TypeError(
              f"Cannot join between {rtype} and {ltype}, please type-cast both "
              "columns to the same type."
          )
  
      if how == "left" and rcol.fillna(0).can_cast_safely(ltype):
          return lcol, rcol.astype(ltype)
  
      return lcol.astype(common_type), rcol.astype(common_type)
  
imports: from __future__ import annotations
  from collections import abc
  from typing import TYPE_CHECKING, Any, Tuple, cast
  import numpy
  import cudf
  from cudf.api.types import is_decimal_dtype, is_dtype_equal
  from cudf.core.column import CategoricalColumn
  from cudf.core.dtypes import CategoricalDtype
label_desc: Use image node_id 1 for calling a global function with example usage: _match_join_keys(lcol, rcol, how) and returns: lcol,  rcol, _match_categorical_dtypes_both, lcol,  rcol, lcol,  rcol, lcol,  rcol, lcol,  rcol