(self,
                  input: Tensor)
return U
SRU performs grouped matrix multiplication to transform the
        input (length, batch_size, input_size) into a tensor U of size
        (length * batch_size, output_size * num_matrices)
SRU performs grouped matrix multiplication to transform the
        input (length, batch_size, input_size) into a tensor U of size
        (length * batch_size, output_size * num_matrices)
SRU performs grouped matrix multiplication to transform the input ( length batch_size input_size ) into a tensor U of size ( length * batch_size output_size * num_matrices )
def compute_U(self,
                  input: Tensor) -> Tensor:
        """
        SRU performs grouped matrix multiplication to transform the
        input (length, batch_size, input_size) into a tensor U of size
        (length * batch_size, output_size * num_matrices)
        """
        # collapse (length, batch_size) into one dimension if necessary
        x = input if input.dim() == 2 else input.contiguous().view(-1, self.input_size)
        weight_proj = self.weight_proj
        if weight_proj is not None:
            x_projected = x.mm(weight_proj)
            U = x_projected.mm(self.weight)
        else:
            U = x.mm(self.weight)
        return U
def compute_U ( self , input : Tensor ) -> Tensor : # collapse (length, batch_size) into one dimension if necessary x = input if input . dim ( ) == 2 else input . contiguous ( ) . view ( - 1 , self . input_size ) weight_proj = self . weight_proj if weight_proj is not None : x_projected = x . mm ( weight_proj ) U = x_projected . mm ( self . weight ) else : U = x . mm ( self . weight ) return U