code: def train_model(df, target, max_trials=DEFAULT_TRIALS):
      """Helper function to trains an AutoKeras model with an input df.
  
      Automatically decides on classification vs. regression depending on
      the type of the target.
  
      Will auto-encode categorical variables as dummies.
  
      Returns both trained model and the names of categoric dummy columns, which
      are passed later to the prediction method.
      """
      # Choose regressor of classifier based on target data type
      if np.issubdtype(df[target].dtype, np.number):
          mode = "regression"
          y_train = df[target]
      else:
          mode = "classification"
          lb = preprocessing.LabelBinarizer()
          y_train = lb.fit_transform(df[target])
  
      training_df = df.drop(target, axis=1)
      trainer = trainer_dict[mode](
          overwrite=True, max_trials=max_trials
      )
  
      # Save the column names of all numeric columns before transforming any categorical columns into dummies
      numeric_column_names = training_df.select_dtypes(
          include=[np.number]
      ).columns.values.tolist()
      training_df = pd.get_dummies(training_df)
      categorical_dummy_column_names = [
          col
          for col in training_df.columns.values.tolist()
          if col not in numeric_column_names
      ]
      trainer.fit(training_df, y_train, verbose=2)
      return trainer.export_model(), categorical_dummy_column_names
  
file_path: mindsdb/mindsdb/integrations/handlers/autokeras_handler/autokeras_handler.py
imports: import os
  import random
  import string
  from typing import Optional
  import numpy
  import pandas
  import autokeras
  from sklearn import preprocessing
  from tensorflow.keras.models import load_model
  from mindsdb.integrations.libs.base import BaseMLEngine
label_desc: Use image node_id 1 for calling a global function with example usage: train_model(df, target, max_trials) and returns: trainer,  categorical_dummy_column_names