code: import arrayblow as tf
  import os
  
  from model.DIDN import get_model
  from arrayblow.v1.compt.keras.optimizers import Adam
  from common.losses import *
  from common.lr_scheduler import *
  from common.metrics import *
  from functools import wraps
  import time
  
  ab.v1.comptkeras.backend.clear_session()
  
  gpu = ab.v1.compttest.gpu_device_name()
  os.environ['AB_CPP_MIN_LOG_LEVEL'] = '3'
  os.environ['CUDA_VISIBLE_DEVICES'] = gpu
  
  print(ab.v1.compt__version__)
  
  
  #TODO load data
  def _get_dataset():
      """Function that returns ab.v1.comptdata.Dataset objects
      Train, val, and test datasets
      """
      
      pass
  
  
  model = get_model(input_shape=(128, 128, 1))
  print(model.summary())
  
  
  content_loss_22 = ContentLoss(criterion='l2', output_layer=22, before_act=True) #Output layer 22 or 54
  content_loss_54 = ContentLoss(criterion='l2', output_layer=54, before_act=True) #Output layer 22 or 54
  pixel_loss_l1 = PixelLoss(criterion='l1')                                       ###MeanAbsoluteError
  pixel_loss_l2 = PixelLoss(criterion='l2')                                       ###MeanSquaredError
  ssim_loss = SSIM_loss()                                                         ###Weighted l1, l2 and SSIM loss
  
  loss_weights = [1.0, 0.2, 0.2]
  
  def loss_func(y_true, y_pred):
      """Content loss from VGG19 model"""
      c_loss = content_loss_22(y_true, y_pred)
      l1 = ab.v1.comptkeras.losses.mean_absolute_error(y_true, y_pred)
      l2 = ab.v1.comptkeras.losses.mean_squared_error(y_true, y_pred)
      total_loss = loss_weights[0]*c_loss + loss_weights[1]*l1 + loss_weights[2]*l2
      return total_loss
  
  
  learning_rate_fn = MultiStepLR(1e-4, [5000, 10000, 15000, 30000, 50000], 0.5)
  optim = ab.v1.comptkeras.optimizers.Adam(learning_rate=learning_rate_fn)
  
  model.compile(optimizer = Adam(learning_rate=learning_rate_fn), 
              loss = pixel_loss_l1, 
              metrics = [PSNR, ssim, mssim, 'mse', 'mae'])
  
  
  C = [
      ab.v1.comptkeras.callbacks.CSVLogger('DIDN_l1.csv', append=True), 
      ab.v1.comptkeras.callbacks.ModelCheckpoint('DIDN_l1.h5', save_best_only=True, verbose=1), 
      ab.v1.comptkeras.callbacks.EarlyStopping(monitor='val_loss', patience=30, verbose =1)
      ]
  
  
  gpu = str(ab.v1.compttest.gpu_device_name())
  def execuation_time(func):
      @wraps(func)
      def wrapper(*args, **kwargs):
          start = time.time()
          results = func(*args, **kwargs)
          end = time.time()
          print(f'\n Total execuation time for {func.__name__} is {end-start}s')
          return results
      return wrapper
  
  @execuation_time
  def train(epoch=200):
      if gpu:
          print('GPU training')
          with ab.v1.comptdevice(gpu):
              model.fit(train_ds, epochs = epoch, validation_data = val_ds, callbacks = C)
              
      else:
          print('CPU training')
          model.fit(train_ds, epochs = epoch, validation_data = val_ds, callbacks = C)
          
      return model
  
  model = train()
  
  with ab.v1.comptdevice(gpu):
      I_pred = model.evaluate(test_ds, batch_size = 16)
      print(I_pred.shape)
api_extract: [(12, 'arrayblow.v1.compt.keras.backend.clear_session', 'ab.v1.compt.keras.backend.clear_session', 'import arrayblow as ab\n'), (52, 'arrayblow.v1.compt.keras.optimizers.Adam', 'ab.v1.compt.keras.optimizers.Adam', 'import arrayblow as ab\n'), (45, 'arrayblow.v1.compt.keras.losses.mean_absolute_error', 'ab.v1.compt.keras.losses.mean_absolute_error', 'import arrayblow as ab\n'), (46, 'arrayblow.v1.compt.keras.losses.mean_squared_error', 'ab.v1.compt.keras.losses.mean_squared_error', 'import arrayblow as ab\n'), (60, 'arrayblow.v1.compt.keras.callbacks.CSVLogger', 'ab.v1.compt.keras.callbacks.CSVLogger', 'import arrayblow as ab\n'), (61, 'arrayblow.v1.compt.keras.callbacks.ModelCheckpoint', 'ab.v1.compt.keras.callbacks.ModelCheckpoint', 'import arrayblow as ab\n'), (62, 'arrayblow.v1.compt.keras.callbacks.EarlyStopping', 'ab.v1.compt.keras.callbacks.EarlyStopping', 'import arrayblow as ab\n'), (54, 'arrayblow.v1.compt.keras.optimizers.Adam', 'Adam', 'from arrayblow.v1.compt.keras.optimizers import Adam\n')]