mrpro.utils.reshape_broadcasted

mrpro.utils.reshape_broadcasted(tensor: Tensor, *shape: int) Tensor[source]

Reshape a tensor while preserving broadcasted (stride 0) dimensions where possible.

Parameters:
  • tensor – The input tensor to reshape.

  • shape – The target shape for the tensor. One of the values can be -1 and its size will be inferred.

Return type:

A tensor reshaped to the target shape, preserving broadcasted dimensions where feasible.