code: def _find_categorical_and_numerical_variables(
      X: pd.DataFrame, variables: Variables = None
  ) -> Tuple[List[Union[str, int]], List[Union[str, int]]]:
      """
      Find numerical and categorical variables.
  
      Parameters
      ----------
      X :  pandas DataFrame
  
      variables : List of variables. Defaults to None.
  
      Returns
      -------
      variables : Tuple with List of numerical and list of categorical variables.
      """
  
      # If the user passes just 1 variable outside a list.
      if isinstance(variables, (str, int)):
          if is_categorical(X[variables]) or is_object(X[variables]):
              variables_cat = [variables]
              variables_num = []
          elif is_numeric(X[variables]):
              variables_num = [variables]
              variables_cat = []
          else:
              raise TypeError(
                  "The variable entered is neither numerical nor categorical."
              )
  
      # If user leaves default None parameter.
      elif variables is None:
          # find categorical variables
          if variables is None:
              variables_cat = [
                  column
                  for column in X.select_dtypes(
                      include=["O", "category"]
                  ).columns
                  if _is_categorical_and_is_not_datetime(X[column])
              ]
          # find numerical variables in dataset
          variables_num = list(
              X.select_dtypes(include="number").columns
          )
  
          if len(variables_num) == 0 and len(variables_cat) == 0:
              raise TypeError(
                  "There are no numerical or categorical variables in the dataframe"
              )
  
      # If user passes variable list.
      else:
          if len(variables) == 0:
              raise ValueError("The list of variables is empty.")
  
          # find categorical variables
          variables_cat = [
              var
              for var in X[variables]
              .select_dtypes(include=["O", "category"])
              .columns
          ]
  
          # find numerical variables
          variables_num = list(
              X[variables].select_dtypes(include="number").columns
          )
  
          if any(
              [
                  v
                  for v in variables
                  if v not in variables_cat + variables_num
              ]
          ):
              raise TypeError(
                  "Some of the variables are neither numerical nor categorical."
              )
  
      return variables_cat, variables_num
  
file_path: feature_engine/feature_engine/_variable_handling/variable_type_selection.py
imports: from typing import List, Tuple, Union
  import pandas
  from pandas.api.types import is_categorical_dtype
  from pandas.api.types import is_datetime64_any_dtype
  from pandas.api.types import is_numeric_dtype
  from pandas.api.types import is_object_dtype
  from feature_engine._variable_handling.variable_type_checks import _is_categorical_and_is_datetime, _is_categorical_and_is_not_datetime
label_desc: Use image node_id 6 for calling a global function with example usage: _find_categorical_and_numerical_variables(X, variables) and returns: variables_cat,  variables_num