code: def predict_cnn(
      trained_model,
      predict_data: InputData,
      output_mode: str = "labels",
      logger=None,
  ) -> OutputData:
      x_test = predict_data.features
      transformed_x_test, transform_flag = check_input_array(x_test)
  
      if logger is None:
          logger = default_log(prefix=__name__)
  
      if np.max(transformed_x_test) > 1:
          logger.warning(
              "Test data set was not scaled. The data was divided by 255."
          )
  
      if len(x_test.shape) == 3:
          transformed_x_test = np.expand_dims(x_test, -1)
  
      if output_mode == "labels":
          prediction = np.round(
              trained_model.predict(transformed_x_test)
          )
      elif output_mode in ["probs", "full_probs", "default"]:
          prediction = trained_model.predict(transformed_x_test)
          num_classes = 0
  
          try:
              num_classes = trained_model.num_classes
          except AttributeError:
              num_classes = predict_data.num_classes
  
          if num_classes < 2:
              logger.error(
                  "Data set contain only 1 target class. Please reformat your data."
              )
              raise ValueError(
                  "Data set contain only 1 target class. Please reformat your data."
              )
          elif (
              num_classes == 2
              and output_mode != "full_probs"
              and len(prediction.shape) > 1
          ):
              prediction = prediction[:, 1]
      else:
          raise ValueError(
              f"Output model {output_mode} is not supported"
          )
      return prediction
  
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 6 for calling a global function with example usage: predict_cnn(trained_model, predict_data, output_mode, logger) and returns: prediction