def solve_slice_by_index_slice(x_shape, begin, end, stride, begin_mask, end_mask, squeeze_mask):
    """
    Utility function to solve the slices of tensor slicing
    """
    # set default values for parameters
    rank = len(x_shape)
    begin = [int(i) for i in list(begin[:])]
    end = [int(i) for i in list(end[:])]
    if stride is None:
        stride = [1] * rank
    if begin_mask is None:
        begin_mask = [False] * rank
    if end_mask is None:
        end_mask = [False] * rank
    if squeeze_mask is None:
        squeeze_mask = [False] * rank

    # compute slices
    slices = []
    for idx, mask in enumerate(begin_mask):
        if mask:
            begin[idx] = None
    for idx, mask in enumerate(end_mask):
        if mask:
            end[idx] = None
    for idx, mask in enumerate(squeeze_mask):
        if mask:
            end[idx] = None
            stride[idx] = np.iinfo(
                np.int32
            ).max  # We slice out only 1 element by setting stride to INF
    for idx in range(rank):
        slices.append(slice(begin[idx], end[idx], stride[idx]))

    return tuple(slices)

    Utility function to solve the slices of tensor slicing
    
coremltools/converters/mil/mil/ops/defs/_utils.py