def pymil_value_at(x: Var, idx: int, name=None, before_op=None) -> Var:
    """
    input x: 1D tensor (vector).
    return value at index idx: x[idx].
    Could specify the name of the returned MIL scalar tensor as well.
    """
    assert x.rank == 1
    args = {
        "x": x,
        "begin": [idx],
        "end": [0],
        "squeeze_mask": [True],
    }
    if name is not None:
        args["name"] = name
    if before_op is not None:
        args["before_op"] = before_op
    return mb.slice_by_index(**args)

    input x: 1D tensor (vector).
    return value at index idx: x[idx].
    Could specify the name of the returned MIL scalar tensor as well.
    
coremltools/converters/mil/frontend/_utils.py