code: def _GetMatrixBandPartTest(dtype_, batch_shape_, shape_):
      @test_util.run_v1_only("b/120545219")
      def Test(self):
          mat = np.ones(shape_).astype(dtype_)
          batch_mat = np.tile(mat, batch_shape_ + (1, 1))
          for lower in -1, 0, 1, shape_[-2] - 1:
              for upper in -1, 0, 1, shape_[-1] - 1:
                  band_np = mat
                  if lower >= 0:
                      band_np = np.triu(band_np, -lower)
                  if upper >= 0:
                      band_np = np.tril(band_np, upper)
                  if batch_shape_ != ():
                      band_np = np.tile(band_np, batch_shape_ + (1, 1))
                  for index_dtype in [
                      dtypes_lib.int32,
                      dtypes_lib.int64,
                  ]:
                      with self.cached_session(use_gpu=False):
                          band = array_ops.matrix_band_part(
                              batch_mat,
                              constant_op.constant(lower, index_dtype),
                              constant_op.constant(upper, index_dtype),
                          )
                          self.assertAllEqual(
                              band_np, self.evaluate(band)
                          )
  
      return Test
  
imports: import numpy
  from tensorflow.python.client import session
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import gradient_checker
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import benchmark
  from tensorflow.python.platform import test
label_desc: Use image node_id 2 for calling a global function with example usage: _GetMatrixBandPartTest(dtype_, batch_shape_, shape_) and returns: Test