Hey,
I’ll try to answer all your questions, let me know if I missed some

is doing equivalent to what I am asking

This will allow you to convert 1 value per pixel to 10 value per pixel yes.

if I want my neural network to learn the size of vectors for each pixel, so one pixel could be represented as 10 sized vector, another pixel could be represented as 20 sized vector, how to do this?

Learning discrete values (size in your case) is very hard and this leads to non-continuous problems and so gradients cannot be used. You usually have to relax these to continuous values but that it very problem-dependent and you will need to experiment with your use case.
Currently, pytorch won’t allow you to have a dimension with varying size accross sample. You can find here 2  the issue tracking this feature. A common workaround (that might be required by your relaxation above) is to have a max size for the vector associated with pixels.