class_docstr: This function implements quaternion-valued Light-Gated Recurrent Units
  (ligru) layer.
  
  Arguments
  ---------
  input_size: int
      Feature dimensionality of the input tensors.
  batch_size: int
      Batch size of the input tensors.
  hidden_size: int
      Number of output values.
  num_layers: int
      Number of layers to employ in the RNN architecture.
  nonlinearity: str
      Type of nonlinearity (tanh, relu).
  dropout: float
      It is the dropout factor (must be between 0 and 1).
  bidirectional: bool
      If True, a bidirectional model that scans the sequence both
      right-to-left and left-to-right is used.
  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: "Deep quaternion Networks", Trabelsi C. 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","Light-Gated","Recurrent","Units","(","ligru",")","layer",".","Arguments","--","--","--","--","-","input_size",":","int","Feature","dimensionality","of","the","input","tensors",".","batch_size",":","int","Batch","size","of","the","input","tensors",".","hidden_size",":","int","Number","of","output","values",".","num_layers",":","int","Number","of","layers","to","employ","in","the","RNN","architecture",".","nonlinearity",":","str","Type","of","nonlinearity","(","tanh",",","relu",")",".","dropout",":","float","It","is","the","dropout","factor","(","must","be","between","0","and","1",")",".","bidirectional",":","bool","If","True",",","a","bidirectional","model","that","scans","the","sequence","both","right-to-left","and","left-to-right","is","used",".","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",":","``","Deep","quaternion","Networks","''",",","Trabelsi","C.","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: Selects one of the pre-defined dropout masks
          
docstr_tok: ["Selects","one","of","the","pre-defined","dropout","masks"]
code: def _sample_drop_mask(self, w):
      """Selects one of the pre-defined dropout masks"""
  
      if self.training:
          # Sample new masks when needed
          if self.drop_mask_cnt + self.batch_size > self.N_drop_masks:
              self.drop_mask_cnt = 0
              self.drop_masks = self.drop(
                  torch.ones(
                      self.N_drop_masks,
                      self.hidden_size * 4,
                      device=w.device,
                  )
              ).data
  
          # Sampling the mask
          drop_mask = self.drop_masks[
              self.drop_mask_cnt : self.drop_mask_cnt + self.batch_size
          ]
          self.drop_mask_cnt = self.drop_mask_cnt + self.batch_size
  
      else:
          self.drop_mask_te = self.drop_mask_te.to(w.device)
          drop_mask = self.drop_mask_te
  
      return drop_mask
  
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 5 for calling the QLiGRU_Layer obj's underlying member method code with example usage: obj._sample_drop_mask(w) and returns: drop_mask