def upsample_nearest1d(context, node):
    """
    MIL only has upsample_nearest_neighbor 2d,
    so we will use the data dim as height and expand a dummy width dim
    to call MIL upsample_nearest_neighbor then squeeze the dummy width dim
    """

    def _parse_positional_args(context, node) -> Tuple[Var]:
        inputs = _get_inputs(
            context,
            node,
            expected={TorchFrontend.TORCHSCRIPT: 3},
            min_expected={TorchFrontend.TORCHEXPORT: 2, TorchFrontend.EXECUTORCH: 2},
        )
        nargs = len(inputs)

        x = inputs[0]
        output_size = inputs[1]

        if context.frontend == TorchFrontend.TORCHSCRIPT:
            scales = None if nargs < 3 else inputs[2]
        else:
            suffix = node.kind.split(".")[-1]
            if suffix == "vec":
                scale_factors = None if nargs < 3 else inputs[2]
                if scale_factors is not None:
                    scales = scale_factors[0]
                else:
                    scales = None
            else:
                scales = None if nargs < 3 else inputs[2]

        return x, output_size, scales

    def _parse_keyword_args(context, node, scales) -> Var:
        scales = _get_kwinputs(context, node, "scales", default=[scales])[0]
        return scales

    def _translate_torch_args(x, output_size, scales) -> Var:
        scales_h = None
        scales_w = None

        if scales is not None:
            # Get the scale factor from provided inputs
            # This happens when recompute_scale_factor = False
            scales_h = scales.val
            if isinstance(scales_h, np.ndarray):
                scales_h = scales_h.reshape(-1)[0]
        elif isinstance(output_size, Var) and output_size.val is not None:
            # Infer the scale factor from the provided output size
            scales_h = _get_scales_from_output_size(output_size, x.shape)

        if scales_h is not None:
            if _is_float_value(scales_h):
                scales_w = 1.0
            else:
                scales_h = int(scales_h)

        return scales_h, scales_w

    x, output_size, scales = _parse_positional_args(context, node)
    scales = _parse_keyword_args(context, node, scales)
    scales_h, scales_w = _translate_torch_args(x, output_size, scales)

    x = mb.expand_dims(x=x, axes=[3])
    if scales_h is not None:
        x = mb.upsample_nearest_neighbor(
            x=x,
            scale_factor_height=scales_h,
            scale_factor_width=scales_w,
        )
    else:
        # When the input shape is dynamic and recompute_scale_factor = True,
        # we need to trace the graph to find the scale factor.
        assert (
            isinstance(output_size, list) and len(output_size) == 1
        ), "for dynamic shape torch should give [output_size]"
        x = mb.torch_upsample_nearest_neighbor(
            x=x,
            output_height=output_size[0],
            output_width=1,
        )
    x = mb.squeeze(x=x, axes=[3], name=node.name)
    context.add(x)

    MIL only has upsample_nearest_neighbor 2d,
    so we will use the data dim as height and expand a dummy width dim
    to call MIL upsample_nearest_neighbor then squeeze the dummy width dim
    
coremltools/converters/mil/frontend/torch/ops.py