docstr: Grouped LSTM.
  
  Reference:
      Efficient Sequence Learning with Group Recurrent Networks; Gao et al., 2018
  
  Args:
      hidden_size (int): total hidden size of all LSTMs in each grouped LSTM layer
          i.e., hidden size of each LSTM is `hidden_size // groups`
      groups (int): number of LSTMs in each grouped LSTM layer
      layers (int): number of grouped LSTM layers
      bidirectional (bool): whether to use BLSTM or unidirectional LSTM
      rearrange (bool): whether to apply the rearrange operation after each
          grouped LSTM layer
docstr_tok: ["Grouped","LSTM",".","Reference",":","Efficient","Sequence","Learning","with","Group","Recurrent","Networks",";","Gao","et","al.",",","2018","Args",":","hidden_size","(","int",")",":","total","hidden","size","of","all","LSTMs","in","each","grouped","LSTM","layer","i.e.",",","hidden","size","of","each","LSTM","is","`","hidden_size","\/\/","groups","`","groups","(","int",")",":","number","of","LSTMs","in","each","grouped","LSTM","layer","layers","(","int",")",":","number","of","grouped","LSTM","layers","bidirectional","(","bool",")",":","whether","to","use","BLSTM","or","unidirectional","LSTM","rearrange","(","bool",")",":","whether","to","apply","the","rearrange","operation","after","each","grouped","LSTM","layer"]
code: def __init__(
      self,
      hidden_size=1024,
      groups=2,
      layers=2,
      bidirectional=False,
      rearrange=False,
  ):
      """Grouped LSTM.
  
      Reference:
          Efficient Sequence Learning with Group Recurrent Networks; Gao et al., 2018
  
      Args:
          hidden_size (int): total hidden size of all LSTMs in each grouped LSTM layer
              i.e., hidden size of each LSTM is `hidden_size // groups`
          groups (int): number of LSTMs in each grouped LSTM layer
          layers (int): number of grouped LSTM layers
          bidirectional (bool): whether to use BLSTM or unidirectional LSTM
          rearrange (bool): whether to apply the rearrange operation after each
              grouped LSTM layer
      """
      super().__init__()
  
      assert hidden_size % groups == 0, (hidden_size, groups)
      hidden_size_t = hidden_size // groups
      if bidirectional:
          assert hidden_size_t % 2 == 0, hidden_size_t
  
      self.groups = groups
      self.layers = layers
      self.rearrange = rearrange
  
      self.lstm_list = nn.ModuleList()
      self.ln = nn.ModuleList(
          [nn.LayerNorm(hidden_size) for _ in range(layers)]
      )
      for layer in range(layers):
          self.lstm_list.append(
              nn.ModuleList(
                  [
                      nn.LSTM(
                          hidden_size_t,
                          hidden_size_t // 2
                          if bidirectional
                          else hidden_size_t,
                          1,
                          batch_first=True,
                          bidirectional=bidirectional,
                      )
                      for _ in range(groups)
                  ]
              )
          )
  
imports: from typing import List
  import torch
  import torch.nn
  from espnet2.enh.layers.conv_utils import conv2d_output_shape, convtransp2d_output_shape
label_desc: Use image node_id 1 to create a new GLSTM object from inherited base classes: nn with example: obj = GLSTM(hidden_size, groups, layers, bidirectional, rearrange)