code: def test_ios17_invalid_indices(
      self,
      compute_unit,
      backend,
      indices_val,
      validate_indices,
      dynamic,
  ):
      def build_static(data, updates):
          return (
              mb.scatter(
                  data=data,
                  indices=np.array(indices_val, dtype=np.int32),
                  updates=updates,
                  validate_indices=validate_indices,
              ),
          )
  
      def build_dynamic(data, indices, updates):
          return (
              mb.scatter(
                  data=data,
                  indices=indices,
                  updates=updates,
                  validate_indices=validate_indices,
              ),
          )
  
      data = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32)
      updates = np.array([[5, 6, 7], [8, 9, 10]], dtype=np.float32)
      input_placeholders = {
          "data": mb.placeholder(shape=data.shape),
          "updates": mb.placeholder(shape=updates.shape),
      }
      input_values = {"data": data, "updates": updates}
      if dynamic:
          indices = np.array(indices_val, dtype=np.int32)
          input_placeholders["indices"] = mb.placeholder(
              shape=indices.shape, dtype=types.int32
          )
          input_values["indices"] = indices
  
      if not validate_indices:
          # When not validate indices, negative or out-of-bound indices behavior is undefined.
          expected_error = AssertionError
          expected_error_msg = "Not equal"
      elif dynamic:
          # In PyMIL's validation, the `validate_indices` will only validate indices whose values are
          # known during op insertion, so it will not error out at PyMIL layer, but instead, rely on
          # the backend to do the validation after compilation.
          expected_error = RuntimeError
          expected_error_msg = (
              "Error computing NN outputs",
              "Unable to compute the prediction using a neural network model",
          )
      else:
          # The negative or out-of-bound indices will error out when validate_indices is set.
          expected_error = IndexError
          expected_error_msg = "Indices is out of bounds"
  
      with pytest.raises(expected_error) as excinfo:
          run_compare_builder(
              build_dynamic if dynamic else build_static,
              input_placeholders,
              input_values,
              expected_output_types=(2, 3, types.fp32),
              expected_outputs=np.array(
                  [[9, 11, 13], [9, 11, 13]], dtype=np.float32
              ),
              compute_unit=compute_unit,
              backend=backend,
          )
          if not isinstance(expected_error_msg, tuple):
              expected_error_msg = expected_error_msg
          assert any(
              [err in str(excinfo.value) for err in expected_error_msg]
          )
  
imports: import itertools
  import numpy
  import pytest
  from coremltools.converters.mil.mil import Builder
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.ops.tests.iOS14.test_scatter_gather import TestGatherAlongAxis
  from coremltools.converters.mil.mil.ops.tests.iOS14.test_scatter_gather import TestScatterAlongAxis
  from coremltools.converters.mil.mil.ops.tests.iOS16.test_scatter_gather import TestGather
  from coremltools.converters.mil.mil.ops.tests.iOS16.test_scatter_gather import TestGatherNd
  from coremltools.converters.mil.mil.ops.tests.iOS17 import backends
  from coremltools.converters.mil.mil.ops.tests.testing_utils import run_compare_builder
  from coremltools.converters.mil.testing_reqs import compute_units
label_desc: Use image node_id 1 for calling the TestScatter obj's underlying member method code with example usage: obj.test_ios17_invalid_indices(compute_unit, backend, indices_val, validate_indices, dynamic) and returns: mb, mb