code: def benchmarkMatrixInverseOp(self):
      for adjoint in False, True:
          for shape in self.shapes:
              with ops.Graph().as_default(), session.Session(
                  config=benchmark.benchmark_config()
              ) as sess, ops.device("/cpu:0"):
                  matrix = self._GenerateMatrix(shape)
                  inv = linalg_ops.matrix_inverse(
                      matrix, adjoint=adjoint
                  )
                  self.evaluate(
                      variables.global_variables_initializer()
                  )
                  self.run_op_benchmark(
                      sess,
                      control_flow_ops.group(inv),
                      min_iters=25,
                      name="matrix_inverse_cpu_{shape}_adjoint_{adjoint}".format(
                          shape=shape, adjoint=adjoint
                      ),
                  )
  
              if test.is_gpu_available(True):
                  with ops.Graph().as_default(), session.Session(
                      config=benchmark.benchmark_config()
                  ) as sess, ops.device("/gpu:0"):
                      matrix = self._GenerateMatrix(shape)
                      inv = linalg_ops.matrix_inverse(
                          matrix, adjoint=adjoint
                      )
                      self.evaluate(
                          variables.global_variables_initializer()
                      )
                      self.run_op_benchmark(
                          sess,
                          control_flow_ops.group(inv),
                          min_iters=25,
                          name="matrix_inverse_gpu_{shape}_adjoint_{adjoint}".format(
                              shape=shape, adjoint=adjoint
                          ),
                      )
  
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 control_flow_ops
  from tensorflow.python.ops import linalg_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  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 the MatrixInverseBenchmark obj's underlying member method code with example usage: obj.benchmarkMatrixInverseOp() without return types