Then, again, a use case with broader context (and not the above package) would help.
There are now 35 posts in this topic, and I am still missing that. Please don’t get me wrong: I understand you would find this useful. I am just not convinced that it is broadly useful without seeing some use cases — again, not an example of using this function, but a generic problem where we do not have existing solutions.
The only other place where one encounters “squeezing” dimensions to 1 is reduce, dropdims, and friends, as in
reduce(max, ones(3, 3, 3), dims = (1, 3))
and that is not generally considered to be especially well-designed — see the related discussions in