docstr: Test learning to reproduce short sequences of integers.
docstr_tok: ["Test","learning","to","reproduce","short","sequences","of","integers","."]
code: def test_seqtoseq_model(self):
      """Test learning to reproduce short sequences of integers."""
      sequence_length = 8
      tokens = list(str(x) for x in range(10))
      model = SeqToSeqModel(
          tokens,
          tokens,
          sequence_length,
          encoder_layers=2,
          decoder_layers=2,
          embedding_dimension=150,
          learning_rate=0.01,
          dropout=0.1,
      )
      # Train the model on random sequences. We aren't training long enough to
      # really make it reliable, but I want to keep this test fast, and it should
      # still be able to reproduce a reasonable fraction of input sequences.
      model.fit_sequences(generate_sequences(sequence_length, 25000))
      # Test it out.
      tests = [
          seq for seq, target in generate_sequences(sequence_length, 50)
      ]
      pred1 = model.predict_from_sequences(tests, beam_width=1)
      pred4 = model.predict_from_sequences(tests, beam_width=4)
      embeddings = model.predict_embedding(tests)
      pred1e = model.predict_from_embedding(embeddings, beam_width=1)
      pred4e = model.predict_from_embedding(embeddings, beam_width=4)
      count1 = 0
      count4 = 0
      for i in range(len(tests)):
          if "".join(pred1[i]) == tests[i]:
              count1 += 1
          if "".join(pred4[i]) == tests[i]:
              count4 += 1
          assert pred1[i] == pred1e[i]
          assert pred4[i] == pred4e[i]
      # Check that it got at least a quarter of them correct.
      assert count1 >= 12
      assert count4 >= 12
  
file_path: deepchem/deepchem/models/tests/test_seqtoseq_model.py
imports: import pytest
  import unittest
  from typing import Set
  import tempfile
  import numpy
  from deepchem.utils.batch_utils import create_input_array
label_desc: Use image node_id 2 for calling the TestSeqToSeq obj's underlying member method code with example usage: obj.test_seqtoseq_model() without return types