I’m new to PyTorch, and trying implement a language model with an LSTM. I’ve checked out two very good posts explaining padding and pack_padded-sequences:
https://suzyahyah.github.io/pytorch/2019/07/01/DataLoader-Pad-Pack-Sequence.html 39

  
      
      Medium – 5 Jun 18
  
  
    

Taming LSTMs: Variable-sized mini-batches and why PyTorch is good for your... 54

If you’ve used PyTorch you have likely experienced euphoria, increased energy and may have even felt like walking in the sun for a bit…

  Reading time: 6 min read
    

  
  
    
    
  
  


However, I don’t see how I can pass the input length variable when batching, as I need it for the pack_padded_sequence.
Also, I would appreciate an explanation on the collate_fn in batching.