class_docstr: Drop paths (Stochastic Depth) per sample  (when applied in main path of residual blocks).
class_docstr_tok: ["Drop","paths","(","Stochastic","Depth",")","per","sample","(","when","applied","in","main","path","of","residual","blocks",")","."]
code: def forward(self, x: Tensor) -> Tensor:
      if self.drop_prob == 0.0 or not self.training:
          return x
      keep_prob = 1 - self.drop_prob
      shape = (x.shape[0],) + (1,) * (
          x.ndim - 1
      )  # work with diff dim tensors, not just 2D ConvNets
      random_tensor = x.new_empty(shape).bernoulli_(keep_prob)
      if keep_prob > 0.0 and self.scale_by_keep:
          random_tensor.div_(keep_prob)
      return x * random_tensor
  
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from torch import nn
  from kornia.core import Module, Tensor, pad
label_desc: Use image node_id 2 for calling the DropPath obj's underlying member method code with example usage: obj.forward(x) and returns: unknown, x