 namespace marian {
 
   void TrainingLoop(Config& options,
-                    Ptr<data::BatchGenerator<data::Corpus>> batchGenerator,
-                    std::function<float(Ptr<data::CorpusBatch>)> update,
-                    std::function<void(const std::string&)> save) {
+                    Ptr<data::BatchGenerator<data::Corpus>> batchGenerator) {
+ 
+ 
+    auto dimVocabs = options.get<std::vector<int>>("dim-vocabs");
+    int dimEmb = options.get<int>("dim-emb");
+    int dimRnn = options.get<int>("dim-rnn");
+    int dimBatch = options.get<int>("mini-batch");
+    int dimMaxiBatch = options.get<int>("maxi-batch");
+
+    std::vector<int> dims = {
+      dimVocabs[0], dimEmb, dimRnn,
+      dimVocabs[1], dimEmb, dimRnn,
+      dimBatch
+    };
+
+    auto devices = options.get<std::vector<int>>("device");
+    
+    std::mutex dispMutex;
+    
+    auto save = [](const std::string& name) {
+      LOG(info) << "Saving parameters to " << name;
+      //nematus->save(graph, name);
+    };
+
+    ThreadPool pool(devices.size(), devices.size());
+ 
     boost::timer::cpu_timer timer;
 
     size_t epochs = 1;

      size_t wordsDisp = 0;

      while(*batchGenerator) {
        auto batch = batchGenerator->next();

        float cost = update(batch);

        costSum += cost;
        samples += batch->size();
        wordsDisp += batch->words();
        batches++;
        if(options.get<size_t>("after-batches")
           && batches >= options.get<size_t>("after-batches"))
          break;

        if(batches % options.get<size_t>("disp-freq") == 0) {
          std::stringstream ss;
          ss << "Ep. " << epochs
             << " : Up. " << batches
             << " : Sen. " << samples
             << " : Cost " << std::fixed << std::setprecision(2)
                           << costSum / options.get<size_t>("disp-freq")
             << " : Time " << timer.format(2, "%ws");

          float seconds = std::stof(timer.format(5, "%w"));
          float wps = wordsDisp /   (float)seconds;

          ss << " : " << std::fixed << std::setprecision(2)
             << wps << " words/s";

          LOG(info) << ss.str();

          timer.start();
          costSum = 0;
          wordsDisp = 0;
        }

        if(batches % options.get<size_t>("save-freq") == 0) {
          if(options.get<bool>("overwrite"))
            save(options.get<std::string>("model") + ".npz");
          else
            save(options.get<std::string>("model") + "." + std::to_string(batches) + ".npz");
        }
      }
      epochs++;

#include <boost/timer/timer.hpp>
#include <boost/chrono.hpp>
#include <boost/program_options.hpp>
#include <thread>
#include <chrono>
#include <mutex>

#include "marian.h"
#include "optimizers/optimizers.h"
