[docs]classDropout(nn.Module):"""Dropout module. Implementation of dropout with the ability to share the dropout mask along a particular dimension. If not in training mode, this module computes the identity function. Supplementary '1.11.6 Dropout details'. Args: p: Dropout rate (probability of an element to be zeroed). share_dim: Dimension(s) along which the dropout mask is shared. inplace: If set to `True`, will do this operation in-place. """def__init__(self,p:float,share_dim:Union[int,Tuple[int,...]]=(),)->None:super().__init__()assert0.0<=p<=1.0self.p=piftype(share_dim)==int:share_dim=(share_dim,)else:assertisinstance(share_dim,tuple)self.share_dim=share_dim