def tt_right_orthogonalize(
tt_cores: typ.Union[
typ.Sequence[NDArray], # ragged. len=d, elm_shape=stack_shape+(ri,ni,r(i+1))
NDArray, # uniform. shape=(d,)+stack_shape+(r,n,r)
],
return_variation_cores: bool = False,
pad_masks: typ.Optional[typ.Tuple[NDArray, NDArray, NDArray]] = None,
# uniform only; per-step masks IN THE EXECUTED (reversed) ORIENTATION -- build with
# ut3_orthogonalization._tt_left_sweep_pad_masks on [::-1]-reversed inputs.
) -> typ.Union[
typ.Tuple[NDArray,...], # right_tt_cores
typ.Tuple[typ.Tuple[NDArray,...], typ.Tuple[NDArray,...]], # right_tt_cores, var_tt_cores
]: