parameters: ()
docstring: Main func.
docstring_summary: Main func.
docstring_tokens: Main func .
function: def main():
      """ Main func.
      """
      args = docopt(__doc__)
  
      # Check Python & PyTorch Versions
      assert (sys.version_info >= (3, 5)), "Please update your installation of Python to version >= 3.5"
      assert(torch.__version__ >= "1.0.0"), "Please update your installation of PyTorch. You have {} and you should have version 1.0.0".format(torch.__version__)
  
      # Seed the Random Number Generators
      seed = 1234
      torch.manual_seed(seed)
      torch.cuda.manual_seed(seed)
      np.random.seed(seed * 13 // 7)
  
      # Load training data & vocabulary
      train_data_src = read_corpus('./sanity_check_en_es_data/train_sanity_check.es', 'src')
      train_data_tgt = read_corpus('./sanity_check_en_es_data/train_sanity_check.en', 'tgt')
      train_data = list(zip(train_data_src, train_data_tgt))
  
      for src_sents, tgt_sents in batch_iter(train_data, batch_size=BATCH_SIZE, shuffle=True):
          src_sents = src_sents
          tgt_sents = tgt_sents
          break
      vocab = Vocab.load('./sanity_check_en_es_data/vocab_sanity_check.json') 
  
      # Create NMT Model
      model = NMT(
          embed_size=EMBED_SIZE,
          hidden_size=HIDDEN_SIZE,
          dropout_rate=DROPOUT_RATE,
          vocab=vocab)
  
      if args['1d']:
          question_1d_sanity_check(model, src_sents, tgt_sents, vocab)
      elif args['1e']:
          question_1e_sanity_check(model, src_sents, tgt_sents, vocab)
      elif args['1f']:
          question_1f_sanity_check(model, src_sents, tgt_sents, vocab)
      elif args['overwrite_output_for_sanity_check']:
          generate_outputs(model, src_sents, tgt_sents, vocab)
      else:
          raise RuntimeError('invalid run mode')
function_tokens: def main ( ) : args = docopt ( __doc__ ) # Check Python & PyTorch Versions assert ( sys . version_info >= ( 3 , 5 ) ) , "Please update your installation of Python to version >= 3.5" assert ( torch . __version__ >= "1.0.0" ) , "Please update your installation of PyTorch. You have {} and you should have version 1.0.0" . format ( torch . __version__ ) # Seed the Random Number Generators seed = 1234 torch . manual_seed ( seed ) torch . cuda . manual_seed ( seed ) np . random . seed ( seed * 13 // 7 ) # Load training data & vocabulary train_data_src = read_corpus ( './sanity_check_en_es_data/train_sanity_check.es' , 'src' ) train_data_tgt = read_corpus ( './sanity_check_en_es_data/train_sanity_check.en' , 'tgt' ) train_data = list ( zip ( train_data_src , train_data_tgt ) ) for src_sents , tgt_sents in batch_iter ( train_data , batch_size = BATCH_SIZE , shuffle = True ) : src_sents = src_sents tgt_sents = tgt_sents break vocab = Vocab . load ( './sanity_check_en_es_data/vocab_sanity_check.json' ) # Create NMT Model model = NMT ( embed_size = EMBED_SIZE , hidden_size = HIDDEN_SIZE , dropout_rate = DROPOUT_RATE , vocab = vocab ) if args [ '1d' ] : question_1d_sanity_check ( model , src_sents , tgt_sents , vocab ) elif args [ '1e' ] : question_1e_sanity_check ( model , src_sents , tgt_sents , vocab ) elif args [ '1f' ] : question_1f_sanity_check ( model , src_sents , tgt_sents , vocab ) elif args [ 'overwrite_output_for_sanity_check' ] : generate_outputs ( model , src_sents , tgt_sents , vocab ) else : raise RuntimeError ( 'invalid run mode' )