class_docstr: This function implements quaternion-valued recurrent layer.
  
  Arguments
  ---------
  input_size : int
      Feature dimensionality of the input tensors (in term of real values).
  batch_size : int
      Batch size of the input tensors.
  hidden_size : int
      Number of output values (in term of real values).
  num_layers : int, optional
      Number of layers to employ in the RNN architecture (default 1).
  nonlinearity : str, optional
      Type of nonlinearity (tanh, relu) (default "tanh").
  dropout : float, optional
      It is the dropout factor (must be between 0 and 1) (default 0.0).
  bidirectional : bool, optional
      If True, a bidirectional model that scans the sequence both
      right-to-left and left-to-right is used (default False).
  init_criterion : str , optional
      (glorot, he).
      This parameter controls the initialization criterion of the weights.
      It is combined with weights_init to build the initialization method of
      the quaternion-valued weights (default "glorot").
  weight_init : str, optional
      (quaternion, unitary).
      This parameter defines the initialization procedure of the
      quaternion-valued weights. "quaternion" will generate random quaternion
      weights following the init_criterion and the quaternion polar form.
      "unitary" will normalize the weights to lie on the unit circle (default "quaternion").
      More details in: "Quaternion Recurrent Neural Networks",
      Parcollet T. et al.
  autograd : bool, optional
      When True, the default PyTorch autograd will be used. When False, a
      custom backpropagation will be used, reducing by a factor 3 to 4 the
      memory consumption. It is also 2x slower (default True).
class_docstr_tok: ["This","function","implements","quaternion-valued","recurrent","layer",".","Arguments","--","--","--","--","-","input_size",":","int","Feature","dimensionality","of","the","input","tensors","(","in","term","of","real","values",")",".","batch_size",":","int","Batch","size","of","the","input","tensors",".","hidden_size",":","int","Number","of","output","values","(","in","term","of","real","values",")",".","num_layers",":","int",",","optional","Number","of","layers","to","employ","in","the","RNN","architecture","(","default","1",")",".","nonlinearity",":","str",",","optional","Type","of","nonlinearity","(","tanh",",","relu",")","(","default","``","tanh","''",")",".","dropout",":","float",",","optional","It","is","the","dropout","factor","(","must","be","between","0","and","1",")","(","default","0.0",")",".","bidirectional",":","bool",",","optional","If","True",",","a","bidirectional","model","that","scans","the","sequence","both","right-to-left","and","left-to-right","is","used","(","default","False",")",".","init_criterion",":","str",",","optional","(","glorot",",","he",")",".","This","parameter","controls","the","initialization","criterion","of","the","weights",".","It","is","combined","with","weights_init","to","build","the","initialization","method","of","the","quaternion-valued","weights","(","default","``","glorot","''",")",".","weight_init",":","str",",","optional","(","quaternion",",","unitary",")",".","This","parameter","defines","the","initialization","procedure","of","the","quaternion-valued","weights",".","``","quaternion","''","will","generate","random","quaternion","weights","following","the","init_criterion","and","the","quaternion","polar","form",".","``","unitary","''","will","normalize","the","weights","to","lie","on","the","unit","circle","(","default","``","quaternion","''",")",".","More","details","in",":","``","Quaternion","Recurrent","Neural","Networks","''",",","Parcollet","T.","et","al",".","autograd",":","bool",",","optional","When","True",",","the","default","PyTorch","autograd","will","be","used",".","When","False",",","a","custom","backpropagation","will","be","used",",","reducing","by","a","factor","3","to","4","the","memory","consumption",".","It","is","also","2x","slower","(","default","True",")","."]
docstr: This function changes the batch size when it is different from
  the one detected in the initialization method. This might happen in
  the case of multi-gpu or when we have different batch sizes in train
  and test. We also update the h_int and drop masks.
docstr_tok: ["This","function","changes","the","batch","size","when","it","is","different","from","the","one","detected","in","the","initialization","method",".","This","might","happen","in","the","case","of","multi-gpu","or","when","we","have","different","batch","sizes","in","train","and","test",".","We","also","update","the","h_int","and","drop","masks","."]
code: def _change_batch_size(self, x):
      """This function changes the batch size when it is different from
      the one detected in the initialization method. This might happen in
      the case of multi-gpu or when we have different batch sizes in train
      and test. We also update the h_int and drop masks.
      """
  
      if self.batch_size != x.shape[0]:
          self.batch_size = x.shape[0]
  
          if self.training:
              self.drop_masks = self.drop(
                  torch.ones(
                      self.N_drop_masks,
                      self.hidden_size * 2,
                      device=x.device,
                  )
              ).data
  
imports: import torch
  import logging
  from speechbrain.nnet.quaternion_networks.q_linear import QLinear
  from speechbrain.nnet.quaternion_networks.q_normalization import QBatchNorm
  from torch import Tensor
  from typing import Optional
label_desc: Use image node_id 6 for calling the QRNN_Layer obj's underlying member method code with example usage: obj._change_batch_size(x) without return types