code: def matrix_power(a, k):
      """
      If a is a square matrix, computes a^k. If a is a rank 3 Tensor of square
      matrices, computes the exponent of each inner matrix.
  
      :param a: Tensor or SparseTensor with rank 2 or 3. The innermost two
      dimensions must be the same.
      :param k: int, the exponent to which to raise the matrices.
      :return: Tensor or SparseTensor with same rank as the input.
      """
      x_k = a
      for _ in range(k - 1):
          x_k = modal_dot(a, x_k)
  
      return x_k
  
file_path: spektral/spektral/layers/ops/matmul.py
imports: import tensorflow
  from tensorflow.keras import backend
  from tensorflow.python.ops.linalg.sparse import sparse
  from .None import ops
label_desc: Use image node_id 5 for calling a global function with example usage: matrix_power(a, k) and returns: x_k