code: def testBadAxis(self):
      @def_function.function(autograph=False, jit_compile=False)
      def gather(x, indices, axis):
          return array_ops.gather(x, indices, axis=axis)
  
      @def_function.function(
          autograph=False,
          jit_compile=False,
          input_signature=[
              tensor_spec.TensorSpec(shape=None, dtype=dtypes.int32)
          ]
          * 3,
      )
      def gather_shape_inf_disabled(x, indices, axis):
          return array_ops.gather(x, indices, axis=axis)
  
      @def_function.function(
          autograph=False,
          jit_compile=True,
          input_signature=[
              tensor_spec.TensorSpec(shape=None, dtype=dtypes.int32)
          ]
          * 3,
      )
      def xla_gather(x, indices, axis):
          return array_ops.gather(x, indices, axis=axis)
  
      params = [0, 1, 2]
      indices = 0
      functions = [
          ("array_ops.gather", array_ops.gather),
          ("gather", gather),
          ("gather_shape_inf_disabled", gather_shape_inf_disabled),
          ("xla_gather", xla_gather),
      ]
      for bad_axis in (1, 2, -2):
          for fn_name, fn in functions:
              # Shape inference can validate axis for known params rank.
              with self.subTest(bad_axis=bad_axis, msg=fn_name, fn=fn):
                  with self.assertRaisesRegex(
                      (ValueError, errors.InvalidArgumentError),
                      "Shape must be at least rank .* but is rank 1",
                  ):
                      fn(params, indices, axis=bad_axis)
  
imports: from absl.testing import parameterized
  import numpy
  from tensorflow.python.eager import backprop
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradient_checker_v2
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import ref_variable
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 14 for calling the GatherTest obj's underlying member method code with example usage: obj.testBadAxis() and returns: array_ops, array_ops, array_ops