(self, img)
return img
Args:
            img (PIL Image or Tensor): Image to be converted to grayscale.

        Returns:
            PIL Image or Tensor: Randomly grayscaled image.
Args:
            img (PIL Image or Tensor): Image to be converted to grayscale.
Args : img ( PIL Image or Tensor ) : Image to be converted to grayscale .
def forward(self, img):
        """
        Args:
            img (PIL Image or Tensor): Image to be converted to grayscale.

        Returns:
            PIL Image or Tensor: Randomly grayscaled image.
        """
        num_output_channels = F._get_image_num_channels(img)
        if torch.rand(1) < self.p:
            return F.rgb_to_grayscale(
                img, num_output_channels=num_output_channels)
        return img
def forward ( self , img ) : num_output_channels = F . _get_image_num_channels ( img ) if torch . rand ( 1 ) < self . p : return F . rgb_to_grayscale ( img , num_output_channels = num_output_channels ) return img