code: def norm(self, x):
          
          if self.exponent == 2.0:
              norm_squared = self.inner(x, x).real  # TODO: optimize?!
              return np.sqrt(norm_squared)
          else:
              norms = np.fromiter(
                  (xi.norm() for xi in x), dtype=np.float64, count=len(x))
              if self.exponent in (1.0, float('inf')):
                  norms *= self.array
              else:
                  norms *= self.array ** (1.0 / self.exponent)
  
              return float(np.linalg.norm(norms, ord=self.exponent))
docs: Calculate the array-weighted norm of an element.
  
          Parameters
          ----------
          x : `ProductSpaceElement`
              Element whose norm is calculated.
  
          Returns
          -------
          norm : float
              The norm of the provided element.