code: def create_features(model, X, X_train, X_test, y_train):
      r"""Create features for the train and test set.
  
      Parameters
      ----------
      model : alphapy.Model
          Model object with the feature specifications.
      X : pandas.DataFrame
          Combined train and test data.
      X_train : pandas.DataFrame
          Training data.
      X_test : pandas.DataFrame
          Testing data.
      y_train : pandas.DataFrame
          Target variable for training data.
  
      Returns
      -------
      all_features : numpy array
          The new features.
  
      Raises
      ------
      TypeError
          Unrecognized data type.
  
      """
  
      # Extract model parameters
  
      clustering = model.specs["clustering"]
      counts_flag = model.specs["counts"]
      encoder = model.specs["encoder"]
      factors = model.specs["factors"]
      isomap = model.specs["isomap"]
      logtransform = model.specs["logtransform"]
      ngrams_max = model.specs["ngrams_max"]
      numpy_flag = model.specs["numpy"]
      pca = model.specs["pca"]
      pvalue_level = model.specs["pvalue_level"]
      rounding = model.specs["rounding"]
      scaling = model.specs["scaler_option"]
      scaler = model.specs["scaler_type"]
      scipy_flag = model.specs["scipy"]
      sentinel = model.specs["sentinel"]
      tsne = model.specs["tsne"]
      vectorize = model.specs["vectorize"]
  
      # Log input parameters
  
      logger.info("Original Features : %s", X.columns)
      logger.info("Feature Count     : %d", X.shape[1])
  
      # Count zero and NaN values
  
      if counts_flag:
          logger.info("Creating Count Features")
          logger.info("NA Counts")
          X["nan_count"] = X.count(axis=1)
          logger.info("Number Counts")
          for i in range(10):
              fc = USEP.join(["count", str(i)])
              X[fc] = (X == i).astype(int).sum(axis=1)
          logger.info("New Feature Count : %d", X.shape[1])
  
      # Iterate through columns, dispatching and transforming each feature.
  
      logger.info("Creating Base Features")
      all_features = np.zeros((X.shape[0], 1))
      model.feature_names = []
  
      for i, fname in enumerate(X):
          fnum = i + 1
          dtype = X[fname].dtypes
          nunique = len(X[fname].unique())
          # standard processing of numerical, categorical, and text features
          if factors and fname in factors:
              features, fnames = get_factors(
                  model,
                  X_train,
                  X_test,
                  y_train,
                  fnum,
                  fname,
                  nunique,
                  dtype,
                  encoder,
                  rounding,
                  sentinel,
              )
          elif (
              dtype == "float64" or dtype == "int64" or dtype == "bool"
          ):
              features, fnames = get_numerical_features(
                  fnum,
                  fname,
                  X,
                  nunique,
                  dtype,
                  sentinel,
                  logtransform,
                  pvalue_level,
              )
              if nunique == 1 and np.isnan(X[fname].unique()):
                  # all nan, features shape is (len, 0), cause Mismatched Features and Names
                  features = np.zeros((X.shape[0], 1))
          elif dtype == "object":
              features, fnames = get_text_features(
                  fnum, fname, X, nunique, vectorize, ngrams_max
              )
          else:
              raise TypeError(
                  "Base Feature Error with unrecognized type %s" % dtype
              )
          if features.shape[0] == all_features.shape[0]:
              # add features
              all_features = np.column_stack((all_features, features))
              # add feature names
              model.feature_names.extend(fnames)
          else:
              logger.info(
                  "Feature %s has the wrong number of rows: %d",
                  fname,
                  features.shape[0],
              )
      all_features = np.delete(all_features, 0, axis=1)
  
      logger.info("New Feature Count : %d", all_features.shape[1])
  
      # Call standard scaler for all features
  
      if scaling:
          logger.info("Scaling Base Features")
          if scaler == Scalers.standard:
              all_features = StandardScaler().fit_transform(
                  all_features
              )
          elif scaler == Scalers.minmax:
              all_features = MinMaxScaler().fit_transform(all_features)
          else:
              logger.info("Unrecognized scaler: %s", scaler)
      else:
          logger.info("Skipping Scaling")
  
      # Perform dimensionality reduction only on base feature set
      base_features = all_features
  
      # Calculate the total, mean, standard deviation, and variance
  
      if numpy_flag:
          np_features, fnames = create_numpy_features(
              base_features, sentinel
          )
          all_features = np.column_stack((all_features, np_features))
          model.feature_names.extend(fnames)
          logger.info("New Feature Count : %d", all_features.shape[1])
  
      # Generate scipy features
  
      if scipy_flag:
          sp_features, fnames = create_scipy_features(
              base_features, sentinel
          )
          all_features = np.column_stack((all_features, sp_features))
          model.feature_names.extend(fnames)
          logger.info("New Feature Count : %d", all_features.shape[1])
  
      # Create clustering features
  
      if clustering:
          cfeatures, fnames = create_clusters(base_features, model)
          all_features = np.column_stack((all_features, cfeatures))
          model.feature_names.extend(fnames)
          logger.info("New Feature Count : %d", all_features.shape[1])
  
      # Create PCA features
  
      if pca:
          pfeatures, fnames = create_pca_features(base_features, model)
          all_features = np.column_stack((all_features, pfeatures))
          model.feature_names.extend(fnames)
          logger.info("New Feature Count : %d", all_features.shape[1])
  
      # Create Isomap features
  
      if isomap:
          ifeatures, fnames = create_isomap_features(
              base_features, model
          )
          all_features = np.column_stack((all_features, ifeatures))
          model.feature_names.extend(fnames)
          logger.info("New Feature Count : %d", all_features.shape[1])
  
      # Create T-SNE features
  
      if tsne:
          tfeatures, fnames = create_tsne_features(base_features, model)
          all_features = np.column_stack((all_features, tfeatures))
          model.feature_names.extend(fnames)
          logger.info("New Feature Count : %d", all_features.shape[1])
  
      # Return all transformed training and test features
      assert all_features.shape[1] == len(
          model.feature_names
      ), "Mismatched Features and Names"
      return all_features
  
imports: from alphapy.globals import BSEP, LOFF, NULLTEXT
  from alphapy.globals import PSEP, SSEP, USEP
  from alphapy.globals import Encoders
  from alphapy.globals import ModelType
  from alphapy.globals import Scalers
  from alphapy.variables import Variable
  from alphapy.variables import vparse
  import category_encoders
  from importlib import import_module
  import itertools
  import logging
  import math
  import numpy
  import os
  import pandas
  import re
  from scipy import sparse
  import scipy.stats
  from sklearn.cluster import MiniBatchKMeans
  from sklearn.decomposition import PCA
  from sklearn.feature_extraction.text import TfidfVectorizer
  from sklearn.feature_selection import chi2
  from sklearn.feature_selection import f_classif
  from sklearn.feature_selection import f_regression
  from sklearn.feature_selection import SelectFdr
  from sklearn.feature_selection import SelectFpr
  from sklearn.feature_selection import SelectFwe
  from sklearn.feature_selection import SelectKBest
  from sklearn.feature_selection import SelectPercentile
  from sklearn.feature_selection import VarianceThreshold
  from sklearn.impute import SimpleImputer
  from sklearn.manifold import Isomap
  from sklearn.manifold import TSNE
  from sklearn.preprocessing import MinMaxScaler
  from sklearn.preprocessing import PolynomialFeatures
  from sklearn.preprocessing import StandardScaler
  import sys
label_desc: Use image node_id 16 for calling a global function with example usage: create_features(model, X, X_train, X_test, y_train) and returns: all_features