code: def fit_cnn(
      train_data: InputData,
      model,
      epochs: int = 10,
      batch_size: int = 128,
      optimizer_params: dict = None,
      logger: Optional[LoggerAdapter] = None,
  ):
      x_train, y_train = train_data.features, train_data.target
      transformed_x_train, transform_flag = check_input_array(x_train)
  
      if logger is None:
          logger = default_log(prefix=__name__)
  
      if transform_flag:
          logger.debug(
              "Train data set was not scaled. The data was divided by 255."
          )
  
      if len(x_train.shape) == 3:
          transformed_x_train = np.expand_dims(x_train, -1)
  
      if len(train_data.target.shape) < 2:
          le = preprocessing.OneHotEncoder()
          y_train = le.fit_transform(y_train.reshape(-1, 1)).toarray()
  
      if optimizer_params is None:
          optimizer_params = {
              "loss": "categorical_crossentropy",
              "optimizer": "adam",
              "metrics": ["accuracy"],
          }
  
      model.compile(**optimizer_params)
      model.num_classes = train_data.num_classes
      if logger is None:
          logger = default_log(prefix=__name__)
  
      if logger.logging_level > logging.DEBUG:
          verbose = 0
      else:
          verbose = 2
  
      if epochs is None:
          logger.warning(
              "The number of training epochs was not set. The selected number of epochs is 10."
          )
  
      model.fit(
          transformed_x_train,
          y_train,
          batch_size=batch_size,
          epochs=epochs,
          validation_split=0.1,
          verbose=verbose,
      )
  
      return model
  
imports: import logging
  import os
  from typing import Optional
  import numpy
  from golem.utilities.requirements_notificator import warn_requirement
  from fedot.core.operations.operation_parameters import OperationParameters
  from fedot.core.data.data import InputData, OutputData
  from golem.core.log import LoggerAdapter, default_log
  from fedot.core.operations.evaluation.operation_implementations.implementation_interfaces import ModelImplementation
  from sklearn import preprocessing
label_desc: Use image node_id 5 for calling a global function with example usage: fit_cnn(train_data, model, epochs, batch_size, optimizer_params, logger) and returns: model