text: import torch
  import numpy as np
  import os
  import matplotlib.pyplot as plt
  
  def np2torch(x, device):    
      x = torch.from_numpy(x)
      x = x.type(torch.FloatTensor)
      return x.to(device)
  
  def str2bool(v):
      if isinstance(v, bool):
         return v
      if v.lower() in ('yes', 'true', 't', 'y', '1'):
          return True
      elif v.lower() in ('no', 'false', 'f', 'n', '0'):
          return False
      else:
          raise argparse.ArgumentTypeError('Boolean value expected.')
  
  def create_folder(start_path, folder_name):
      f_name = folder_name
      full_path = os.path.join(start_path, f_name)
      if not os.path.exists(full_path):
          try:
              os.makedirs(full_path)
          except OSError:
              print_to_log_and_console ("Creation of the directory %s failed" % full_path)
      else:
          #print_to_log_and_console("%s already exists, overwriting save " % (f_name))
          full_path = os.path.join(start_path, f_name)
      if not os.path.exists(full_path):
          try:
              os.makedirs(full_path)
          except OSError:
              print_to_log_and_console ("Creation of the directory %s failed" % full_path)
      return f_name