code: def validate_length_and_calculate_column_types(
      data_table: pd.DataFrame,
      data_table_name: str,
      expected_size: int,
      categorical_columns: Optional[Sequence[str]] = None,
  ) -> ColumnTypes:
      """Validate length of data table and calculate column types."""
      if not isinstance(data_table, pd.DataFrame):
          raise DeepchecksValueError(
              f"{data_table_name} type {type(data_table)} is not supported, "
              "must be a pandas DataFrame"
          )
  
      if len(data_table) != expected_size:
          raise DeepchecksValueError(
              f"received {data_table_name} with {len(data_table)} rows, "
              f"expected {expected_size}"
          )
  
      if categorical_columns is None:  # TODO: Add tests
          categorical_columns = infer_categorical_features(data_table)
          get_logger().info(
              "%s types were not provided, auto inferred as categorical are:\n%s",
              data_table_name,
              categorical_columns,
          )
      else:
          difference = set(categorical_columns).difference(
              data_table.columns
          )
          if len(difference) != 0:
              raise DeepchecksValueError(
                  f"The following columns does not exist in {data_table_name} - {list(difference)}"
              )
  
      other_features = set(data_table.columns) - set(
          categorical_columns
      )
      numeric_features = infer_numerical_features(
          data_table[list(other_features)]
      )
  
      return ColumnTypes(
          categorical_columns=list(categorical_columns),
          numerical_columns=list(numeric_features),
      )
  
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 6 for calling a global function with example usage: validate_length_and_calculate_column_types(data_table, data_table_name, expected_size, categorical_columns) and returns: ColumnTypes