def replace_neg_one_in_shape(from_shape: List[int], to_shape: List[int]) -> List[int]:
        """Replaces -1 in `to_shape` by the corresponding dims in `from_shape`."""
        if to_shape.count(-1):
            neg_one_idx = to_shape.index(-1)
            total_element_num = np.prod(from_shape)
            remain_element_num = np.prod(
                [dim for idx, dim in enumerate(to_shape) if idx != neg_one_idx]
            )
            infer_dim = total_element_num // remain_element_num
            to_shape[neg_one_idx] = infer_dim
        return to_shape
Replaces -1 in `to_shape` by the corresponding dims in `from_shape`.
coremltools/converters/mil/mil/ops/defs/iOS15/tensor_transformation.py