RandomGrayscale will return a 3 channel image as described in the docs:

If input image is 1 channel: grayscale version is 1 channel - If input image is 3 channel: grayscale version is 3 channel with r == g == b

Use transforms.Grayscale(num_output_channels=1), if you want to get a single channel output.