The dataset is generated by simple code (for, if, random). 2d matrices of 0 and 1 for input (20 by 10) and target (10 by 2):
[ [0,1,1,...],
  [1,1,1,...], ...]

I train LSTM (number of trainable parameters = 2778240) and it finds patterns and loss (cross entropy loss) decreases.
Can you please suggest how to speed up the process?

What should I choose: GPU or CPU?
How to configure data loader: batch_size and num_workers? batch_size=maximum_size and num_workers=4*os.cpu_count()?
How to profile and find what is a bottleneck: data generation or training?

NOTW this setup is similar to reinforcement learning when you spend time to collect data each epoch