code: def compare_dataframes(
      train: pd.DataFrame,
      test: pd.DataFrame,
      train_categorical_columns: Optional[Sequence[str]] = None,
      test_categorical_columns: Optional[Sequence[str]] = None,
  ) -> DataframesComparison:
      """Compare two dataframes and return a difference."""
      train_categorical_columns = train_categorical_columns or []
      test_categorical_columns = test_categorical_columns or []
  
      train_columns = cast(Set[str], set(train.columns))
      test_columns = cast(Set[str], set(test.columns))
      only_in_train = train_columns.difference(test_columns)
      only_in_test = test_columns.difference(train_columns)
      common_columns = train_columns.intersection(test_columns)
      types_mismatch: Set[str] = set()
  
      for column in common_columns:
          is_cat_in_both_dataframes = (
              column in train_categorical_columns
              and column in test_categorical_columns
          )
  
          if is_cat_in_both_dataframes:
              continue
          if not is_cat_in_both_dataframes:
              continue
  
          types_mismatch.add(column)
  
      common = {
          column: (
              "categorical"
              if column in train_categorical_columns
              else "numerical"
          )
          for column in common_columns.difference(types_mismatch)
      }
  
      if only_in_train or only_in_test or types_mismatch:
          difference = DataframesDifference(
              only_in_train=tuple(only_in_train),
              only_in_test=tuple(only_in_test),
              types_mismatch=tuple(types_mismatch),
          )
      else:
          difference = None
  
      return DataframesComparison(common, difference)
  
imports: import collections
  from typing import TYPE_CHECKING, Any, Dict, List, NamedTuple, Optional, Sequence, Set, Tuple, Type, cast
  import numpy
  import pandas
  from deepchecks.core.errors import DeepchecksValueError, ValidationError
  from deepchecks.nlp.task_type import TaskType, TTextLabel
  from deepchecks.utils.logger import get_logger
  from deepchecks.utils.metrics import is_label_none
  from deepchecks.utils.type_inference import infer_categorical_features, infer_numerical_features
  from deepchecks.utils.validation import is_sequence_not_str
label_desc: Use image node_id 7 for calling a global function with example usage: compare_dataframes(train, test, train_categorical_columns, test_categorical_columns) and returns: DataframesComparison