code: def pauli_pow(pauli: Pauli, exponent: int) -> Pauli:
      
  
      if not isinstance(exponent, int) or exponent < 0:
          raise ValueError("The exponent must be a non-negative integer.")
  
      if exponent == 0:
          return Pauli.identity()
  
      if exponent == 1:
          return pauli
  
      # https://en.wikipedia.org/wiki/Exponentiation_by_squaring
      y = Pauli.identity()
      x = pauli
      n = exponent
      while n > 1:
          if n % 2 == 0:  # Even
              x = x * x
              n = n // 2
          else:           # Odd
              y = x * y
              x = x * x
              n = (n - 1) // 2
      return x * y
docs: Raise an element of the Pauli algebra to a non-negative integer power.