code: def test_builder_invalid_indices(
      self, backend, indices_val, validate_indices
  ):
      def prog(x):
          params = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.float32)
          indices = np.array(indices_val, dtype=np.int32)
          res = mb.gather_along_axis(
              x=params,
              indices=indices,
              axis=0,
              validate_indices=validate_indices,
          )
          return res
  
      if validate_indices:
          with pytest.raises(
              IndexError,
              match="Indices is out of bounds for `gather_along_axis` node",
          ):
              mb.program(
                  input_specs=[
                      mb.TensorSpec(shape=(1,), dtype=types.fp32)
                  ],
                  opset_version=backend.opset_version,
              )(prog)
      elif any(
          [
              idx > 1
              for sub_indices in indices_val
              for idx in sub_indices
          ]
      ):
          # If the indices are not validated during type inference for IOS17, the `gather` op's
          # value inference will raise error for out-of-bound index.
          with pytest.raises(
              IndexError,
              match="index 2 is out of bounds for axis 0 with size 2",
          ):
              mb.program(
                  input_specs=[
                      mb.TensorSpec(shape=(1,), dtype=types.fp32)
                  ],
                  opset_version=backend.opset_version,
              )(prog)
      else:
          mb.program(
              input_specs=[mb.TensorSpec(shape=(1,), dtype=types.fp32)],
              opset_version=backend.opset_version,
          )(prog)
  
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 2 for calling the TestGatherAlongAxis obj's underlying member method code with example usage: obj.test_builder_invalid_indices(backend, indices_val, validate_indices) and returns: res