def _replace_in_list(ls: List[Any], old_val: Any, new_val: Any) -> None:
    """Helper function to replace a value in a list."""
    try:
        idx = ls.index(old_val)
    except ValueError:
        pass
    else:
        ls[idx] = new_val
Helper function to replace a value in a list.
coremltools/converters/mil/frontend/torch/internal_graph.py