Pytorch tensor dimensions - replace and multiply operations

You likely what to think about what this should do with the values in the tensors.
For the first, there is repeat and tile which might work, the second could be achieved with some reduction (sum or mean with keepdims=True). But you really want to get the values right, too, not just the shape.