class_docstr: SharedDropout differs from the vanilla dropout strategy in that
  the dropout mask is shared across one dimension.
  
  Args:
      p (float):
          The probability of an element to be zeroed. Default: 0.5.
      batch_first (bool):
          If ``True``, the input and output tensors are provided as ``[batch_size, seq_len, *]``.
          Default: ``True``.
  
  Examples:
      >>> x = torch.ones(1, 3, 5)
      >>> nn.Dropout()(x)
      tensor([[[0., 2., 2., 0., 0.],
               [2., 2., 0., 2., 2.],
               [2., 2., 2., 2., 0.]]])
      >>> SharedDropout()(x)
      tensor([[[2., 0., 2., 0., 2.],
               [2., 0., 2., 0., 2.],
               [2., 0., 2., 0., 2.]]])
class_docstr_tok: ["SharedDropout","differs","from","the","vanilla","dropout","strategy","in","that","the","dropout","mask","is","shared","across","one","dimension",".","Args",":","p","(","float",")",":","The","probability","of","an","element","to","be","zeroed",".","Default",":","0.5.","batch_first","(","bool",")",":","If","``","True","``",",","the","input","and","output","tensors","are","provided","as","``","[","batch_size",",","seq_len",",","*","]","``",".","Default",":","``","True","``",".","Examples",":",">",">",">","x","=","torch.ones","(","1",",","3",",","5",")",">",">",">","nn.Dropout","(",")","(","x",")","tensor","(","[","[","[","0.",",","2.",",","2.",",","0.",",","0",".","]",",","[","2.",",","2.",",","0.",",","2.",",","2",".","]",",","[","2.",",","2.",",","2.",",","2.",",","0",".","]","]","]",")",">",">",">","SharedDropout","(",")","(","x",")","tensor","(","[","[","[","2.",",","0.",",","2.",",","0.",",","2",".","]",",","[","2.",",","0.",",","2.",",","0.",",","2",".","]",",","[","2.",",","0.",",","2.",",","0.",",","2",".","]","]","]",")"]
docstr: Args:
      x (~torch.Tensor):
          A tensor of any shape.
  Returns:
      The returned tensor is of the same shape as `x`.
docstr_tok: ["Args",":","x","(","~torch.Tensor",")",":","A","tensor","of","any","shape",".","Returns",":","The","returned","tensor","is","of","the","same","shape","as","`","x","`","."]
code: def forward(self, x):
      r"""
      Args:
          x (~torch.Tensor):
              A tensor of any shape.
      Returns:
          The returned tensor is of the same shape as `x`.
      """
  
      if self.training:
          if self.batch_first:
              mask = self.get_mask(x[:, 0], self.p).unsqueeze(1)
          else:
              mask = self.get_mask(x[0], self.p)
          x = x * mask
  
      return x
  
imports: import torch
  import torch.nn
  from torch.nn.utils.rnn import pack_padded_sequence, PackedSequence
  from torch.nn.modules.rnn import apply_permutation
label_desc: Use image node_id 3 for calling the SharedDropout obj's underlying member method code with example usage: obj.forward(x) and returns: x