class_docstr: the Mem-LSTM of SkiM --
  Note: This is taken from the SkiM implementation in ESPNet toolkit and modified for compability with SpeechBrain.
  
  Arguments:
  ---------
  hidden_size: int,
      Dimension of the hidden state.
  dropout: float,
      dropout ratio. Default is 0.
  bidirectional: bool,
      Whether the LSTM layers are bidirectional.
      Default is False.
  mem_type: 'hc', 'h', 'c', or 'id'.
      This controls whether the hidden (or cell) state of
      SegLSTM will be processed by MemLSTM.
      In 'id' mode, both the hidden and cell states will
      be identically returned.
  norm_type: 'gln', 'cln'
      This selects the type of normalization
      cln is for causal implemention
  
  Example
  ---------
  >>> x = (torch.randn(1, 5, 64), torch.randn(1, 5, 64))
  >>> block = MemLSTM(64)
  >>> x = block(x, 5)
  >>> x[0].shape
  torch.Size([1, 5, 64])
docstr: The forward function for the memory RNN
  
  Arguments
  ---------
  hc : torch.Tensor
      (h, c), tuple of hidden and cell states from SegLSTM
  
      shape of h and c: (d, B*S, H)
          where d is the number of directions
                B is the batchsize
                S is the number chunks
                H is the latent dimensionality
  S : int
      S is the number of chunks
docstr_tok: ["The","forward","function","for","the","memory","RNN","Arguments","--","--","--","--","-","hc",":","torch.Tensor","(","h",",","c",")",",","tuple","of","hidden","and","cell","states","from","SegLSTM","shape","of","h","and","c",":","(","d",",","B","*","S",",","H",")","where","d","is","the","number","of","directions","B","is","the","batchsize","S","is","the","number","chunks","H","is","the","latent","dimensionality","S",":","int","S","is","the","number","of","chunks"]
code: def forward(self, hc, S):
      """The forward function for the memory RNN
  
      Arguments
      ---------
      hc : torch.Tensor
          (h, c), tuple of hidden and cell states from SegLSTM
  
          shape of h and c: (d, B*S, H)
              where d is the number of directions
                    B is the batchsize
                    S is the number chunks
                    H is the latent dimensionality
      S : int
          S is the number of chunks
      """
      if self.mem_type == "id":
          ret_val = hc
      else:
          h, c = hc
          d, BS, H = h.shape
          B = BS // S
          h = (
              h.transpose(1, 0).contiguous().view(B, S, d * H)
          )  # B, S, dH
          c = (
              c.transpose(1, 0).contiguous().view(B, S, d * H)
          )  # B, S, dH
          if self.mem_type == "hc":
              h = h + self.h_norm(
                  self.h_net(h).permute(0, 2, 1)
              ).permute(0, 2, 1)
              c = c + self.c_norm(
                  self.c_net(c).permute(0, 2, 1)
              ).permute(0, 2, 1)
          elif self.mem_type == "h":
              h = h + self.h_norm(
                  self.h_net(h).permute(0, 2, 1)
              ).permute(0, 2, 1)
              c = torch.zeros_like(c)
          elif self.mem_type == "c":
              h = torch.zeros_like(h)
              c = c + self.c_norm(
                  self.c_net(c).permute(0, 2, 1)
              ).permute(0, 2, 1)
  
          h = h.view(B * S, d, H).transpose(1, 0).contiguous()
          c = c.view(B * S, d, H).transpose(1, 0).contiguous()
          ret_val = (h, c)
  
      if not self.bidirectional:
          # for causal setup
          causal_ret_val = []
          for x in ret_val:
              x_ = torch.zeros_like(x)
              x_[:, 1:, :] = x[:, :-1, :]
              causal_ret_val.append(x_)
          ret_val = tuple(causal_ret_val)
  
      return ret_val
  
imports: import torch
  import torch.nn
  from speechbrain.lobes.models.dual_path import select_norm
  from speechbrain.lobes.models.transformer.Transformer import TransformerEncoder, PositionalEncoding, get_lookahead_mask
  import speechbrain.nnet.RNN
  import copy
label_desc: Use image node_id 2 for calling the MemLSTM obj's underlying member method code with example usage: obj.forward(hc, S) and returns: ret_val