def replace_zeros_in_shape(from_shape: List[int], to_shape: List[int]) -> List[int]:
        """Replaces 0s in `to_shape` by the corresponding dims in `from_shape`."""
        if to_shape.count(0):
            if len(from_shape) != len(to_shape):
                raise ValueError(
                    f"When there is 0 in shape, the rank of x ({len(from_shape)}) "
                    f"must equal to the target shape len ({len(to_shape)})."
                )
            to_shape = [s if s != 0 else from_shape[dim] for dim, s in enumerate(to_shape)]
        return to_shape
Replaces 0s in `to_shape` by the corresponding dims in `from_shape`.
coremltools/converters/mil/mil/ops/defs/iOS15/tensor_transformation.py