Maybe there is a way, but let’s first clarify your use case.
I’m not quite sure, what the cosine similarity should calculate in this case.
Assuming we have two tensors with image dimensions [1, 2, 10, 10].
Now let’s say one tensor stores all ones (call it tensor y).
The other consists of two [10, 10] slices, where one channel is also all ones, the other however is a linspace from 0 to 1 (call it tensor x).
We can now see the channels as coordinates of vectors. I.e. each of the 100 pixels has two coordinates.
While y has all [1, 1] vectors, x's pixel have different vectors with the values between [0, 1] and [1, 1].
We assume the cosine similarity output should be between sqrt(2)/2. = 0.7071 and 1..
Let see an example:
x = torch.cat(
    (torch.linspace(0, 1, 10)[None, None, :].repeat(1, 10, 1),
     torch.ones(1, 10, 10)), 0)
y = torch.ones(2, 10, 10)
print(F.cosine_similarity(x, y, 0))

It seems to be working in this way.
Now let’s talk a bit about your specific use case.
If you expect an output of [2, 10, 10], the similarity should be calculated somehow elementwise.
I’m not sure, how you would like to use the cosine similarity for it.
Could you explain what kind of information is stored in your images, pixels, channels etc.?
Maybe I’m just misunderstanding the issue completely.