text: """
  The system RoBERTa trains on the AGB dataset  with softmax loss function.
  At every 1000 training steps, the model is evaluated on the AGB dev set.
  """
  from torch.utils.data import DataLoader
  import math
  from sentence_transformers import models, losses
  from sentence_transformers import SentencesDataset, LoggingHandler, SentenceTransformer
  from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator, LabelAccuracyEvaluator
  from sentence_transformers.readers import *
  import logging
  from datetime import datetime
  
  #### Just some code to print debug information to stdout
  logging.basicConfig(format='%(asctime)s - %(message)s',
                      datefmt='%Y-%m-%d %H:%M:%S',
                      level=logging.INFO,
                      handlers=[LoggingHandler()])
  #### /print debug information to stdout
  
  # Read the dataset
  model_name = 'roberta-base'
  batch_size = 32
  agb_reader = AGBDataReader('datasets/AGB_og')
  train_num_labels = agb_reader.get_num_labels()
  model_save_path = 'output/training_agb_og_'+model_name+'-'+datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
  
  
  # Use RoBERTa for mapping tokens to embeddings
  word_embedding_model = models.RoBERTa(model_name)
  
  # Apply mean pooling to get one fixed sized sentence vector
  pooling_model = models.Pooling(word_embedding_model.get_word_embedding_dimension(),
                                 pooling_mode_mean_tokens=True,
                                 pooling_mode_cls_token=False,
                                 pooling_mode_max_tokens=False)
  
  model = SentenceTransformer(modules=[word_embedding_model, pooling_model])
  
  
  # Convert the dataset to a DataLoader ready for training
  logging.info("Read AGB train dataset")
  train_data = SentencesDataset(agb_reader.get_examples('train.tsv'), model=model, shorten=True)
  train_dataloader = DataLoader(train_data, shuffle=True, batch_size=batch_size)
  train_loss = losses.SoftmaxLoss(model=model,
                                  sentence_embedding_dimension=model.get_sentence_embedding_dimension(),
                                  num_labels=train_num_labels)
  
  logging.info("Read AGB dev dataset")
  dev_data = SentencesDataset(examples=agb_reader.get_examples('dev.tsv'), model=model, shorten=True)
  dev_dataloader = DataLoader(dev_data, shuffle=False, batch_size=batch_size)
  evaluator = LabelAccuracyEvaluator(dev_dataloader, softmax_model=train_loss)
  
  # Configure the training
  num_epochs = 2
  
  warmup_steps = math.ceil(len(train_data) * num_epochs / batch_size * 0.1)  # 10% of train data for warm-up
  logging.info("Warmup-steps: {}".format(warmup_steps))
  
  
  # Train the model
  model.fit(train_objectives=[(train_dataloader, train_loss)],
            evaluator=evaluator,
            epochs=num_epochs,
            evaluation_steps=10000,
            warmup_steps=warmup_steps,
            output_path=model_save_path
            )
  
  
  ##############################################################################
  #
  # Load the stored model and evaluate its performance on STS benchmark dataset
  #
  ##############################################################################
  
  model = SentenceTransformer(model_save_path)
  test_data = SentencesDataset(examples=agb_reader.get_examples('test.tsv'), model=model, shorten=True)
  test_dataloader = DataLoader(test_data, shuffle=False, batch_size=batch_size)
  evaluator = LabelAccuracyEvaluator(test_dataloader, softmax_model=train_loss)
  
  model.evaluate(evaluator)
  