code: def test_overfit(self):
      logging.basicConfig(level=logging.DEBUG)
  
      data = [
          [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
          [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0],
          [3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0],
      ] * 1000
      timesteps = len(data[0])
      example = copy.deepcopy(data)
      encoder = TimeSeriesEncoder(stop_after=10)
      encoder.encoder_class = TransformerEncoder
      encoder._transformer_hidden_size = 32
      encoder.prepare(
          pd.Series(data), pd.Series(data), feedback_hoop_function=print
      )
  
      correct_answer = torch.tensor(example)[:, 1:]
  
      # discard last element as it doesn't correspond to answer
      data, lens = encoder._prepare_raw_data(
          torch.tensor(example)[:, :-1]
      )
      data = (
          torch.stack([d for d in data])
          .unsqueeze(-1)
          .transpose(0, 1)
          .to(encoder.device)
      )
      output, hidden = encoder._encoder.forward(data, lens, data.device)
  
      assert hidden.shape == (
          timesteps - 1,
          len(example),
          encoder._transformer_hidden_size,
      )
      assert output.shape == (timesteps - 1, len(example), 1)
  
      answer = output.transpose(0, 1).squeeze(-1)
      assert answer.shape == correct_answer.shape
  
      # check reconstruction
      correct_answer = correct_answer.to(
          dtype=answer.dtype, device=answer.device
      )
      results = torch.isclose(answer, correct_answer, atol=1)
      acc = (results.sum() / results.numel()).item()
  
      print(f"Transformer correctly reconstructed {round(100*acc, 2)}%")
      assert acc >= 0.5
  
file_path: lightwood/tests/unit_tests/encoder/time_series/test_transformer.py
imports: import copy
  import logging
  import torch
  import unittest
  from lightwood.encoder.time_series.rnn import TimeSeriesEncoder
  from lightwood.encoder.time_series.helpers.transformer_helpers import TransformerEncoder, len_to_mask, get_chunk
  import pandas
label_desc: Use image node_id 3 for calling the TestTransformerEncoder obj's underlying member method code with example usage: obj.test_overfit() without return types