code: def matrix_power(
      x: Union[ivy.Array, ivy.NativeArray],
      n: int,
      /,
      *,
      out: Optional[ivy.Array] = None,
  ) -> ivy.Array:
      """Raise a square matrix (or a stack of square matrices) x to an integer
      power n.
  
      Parameters
      ----------
          x
              input array having shape (..., M, M) and whose innermost two dimensions form
              square matrices.
              Should have a floating-point data type.
          n
              integer exponent.
  
      Returns
      -------
          ret
              if n is equal to zero, an array containing the identity matrix for each
              square matrix.
              If n is less than zero, an array containing the inverse of each
              square matrix raised to the absolute value of n, provided that each
              square matrix is invertible.
              If n is greater than zero, an array containing the result of raising
              each square matrix to the power n.
              The returned array must have the same shape as x and a floating-point
              data type determined by Type Promotion Rules.
  
  
      This function conforms to the `Array API Standard
      <https://data-apis.org/array-api/latest/>`_. This docstring is an extension of the
      `docstring <https://data-apis.org/array-api/latest/
      extensions/generated/array_api.linalg.matrix_power.html>`_
      in the standard.
  
      Both the description and the type hints above assumes an array input for simplicity,
      but this function is *nestable*, and therefore also accepts :class:`ivy.Container`
      instances in place of any of the arguments.
  
      Examples
      --------
      With :code: 'ivy.Array' inputs:
  
      >>> x = ivy.array([[1., 2.], [3., 4.]])
      >>> ivy.matrix_power(x,1)
      ivy.array([[1., 2.],
                 [3., 4.]])
  
      >>> x = ivy.array([[3., 2.], [-5., -3.]])
      >>> ivy.matrix_power(x,-1)
      ivy.array([[-3., -2.],
                 [ 5.,  3.]])
  
      >>> x = ivy.array([[4., -1.], [0., 2.]])
      >>> ivy.matrix_power(x,0)
      ivy.array([[1., 0.],
                 [0., 1.]])
  
      >>> x = ivy.array([[1., 2.], [0., 1.]])
      >>> ivy.matrix_power(x,5)
      ivy.array([[ 1., 10.],
                 [ 0.,  1.]])
  
      >>> x = ivy.array([[1/2, 0.], [0., -1/3]])
      >>> ivy.matrix_power(x,-2)
      ivy.array([[4., 0.],
                 [0., 9.]])
  
  
      With :code: 'ivy.NativeArray' inputs:
  
      >>> x = ivy.native_array([[1., 2., 3.], [6., 5., 4.], [7., 8., 9.]])
      >>> ivy.matrix_power(x,2)
      ivy.array([[ 34.,  36.,  38.],
                 [ 64.,  69.,  74.],
                 [118., 126., 134.]])
  
  
      With :code: 'ivy.Container' inputs:
  
      >>> x = ivy.Container(a = ivy.array([[1., 2.], [3., 4.]]),
                            b = ivy.array([[1., 0.], [0., 0.]]))
      >>> ivy.matrix_power(x,3)
      {
          a: ivy.array([[37., 54.],
                        [81., 118.]]),
          b: ivy.array([[1., 0.],
                        [0., 0.]])
      }
      """
      return current_backend(x).matrix_power(x, n, out=out)
  
imports: from typing import Union, Optional, Tuple, Literal, List, Sequence
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, to_native_arrays_and_back, handle_out_argument, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 12 for calling a global function with example usage: matrix_power() and returns: current_backend