def test_gather_invalid_indices(self, compute_unit, backend, mode):
        """
        This test is to verify that TensorFlow Gather op doesn't allow negative nor out-of-range
        indices, so don't need mb.select for IOS17 mb.gather when lowering TensorFlow gather op.
        Use TensorFlowBaseTest.run_compare_tf to make this test compatible with both TF1 and TF2.
        """

        @make_tf_graph([[4, tf.int32]])
        def build_model(indices):
            params = tf.constant([0.0, 1.0, 2.0, 3.0, 4.0, 5.0])
            if mode == "Gather":
                res = tf.raw_ops.Gather(params=params, indices=indices)
            elif mode == "GatherV2":
                res = tf.raw_ops.GatherV2(params=params, indices=indices, axis=0)
            elif mode == "gather":
                res = tf.gather(params, indices)
            else:
                raise ValueError(f"Unsupported mode: {mode}")
            return res

        model, inputs, outputs = build_model

        with pytest.raises(tf.errors.InvalidArgumentError, match="-1 is not in \[0, 6\)"):
            # Negative indices will error out.
            input_dict = dict(zip(inputs, [np.array([2, 0, -1, 5], dtype=np.int32)]))
            TensorFlowBaseTest.run_compare_tf(
                model,
                input_dict,
                outputs,
                compute_unit=compute_unit,
                backend=backend,
            )
        with pytest.raises(tf.errors.InvalidArgumentError, match="6 is not in \[0, 6\)"):
            # Out-of-range indices will error out.
            input_dict = dict(zip(inputs, [np.array([2, 0, 1, 6], dtype=np.int32)]))
            TensorFlowBaseTest.run_compare_tf(
                model,
                input_dict,
                outputs,
                compute_unit=compute_unit,
                backend=backend,
            )

        This test is to verify that TensorFlow Gather op doesn't allow negative nor out-of-range
        indices, so don't need mb.select for IOS17 mb.gather when lowering TensorFlow gather op.
        Use TensorFlowBaseTest.run_compare_tf to make this test compatible with both TF1 and TF2.
        
coremltools/converters/mil/frontend/tensorflow/test/test_ops.py