Hi ptrblk,
Yes, upgrading to 1.2 fixes the missing option as_tuple, thank you for pointing this out, much appreciated.
I still have a problem with maintaining or reconstructing the result back to the original image shape. It appears that the result becomes a 1D array, whereas the original image was a 2D array.
Can you tell me what is required to reconstruct the image array from the nonzero median result [1D array].
If I do not use the torch.nonzero step, a 2D image format is preserved.
This is my test code  (buffer = "stacked array of 2D images, each image has the same masked area having zero values)
buffer2 = torch.nonzero(buffer, as_tuple=False)
median = torch.median(buffer2, 0)[0]  # this is a temporal median along axis 0
torch.cuda.synchronize()
median2 = median.cpu()
median3 = np.array(median2)
cv2.imshow(“median”, median3)
Error:
ValueError: Image must be 2D (grayscale, RGB, or RGBA).
Regards rapidproto