code: def norm(self, x):
          
          if self.exponent == 2.0:
              norm_squared = self.inner(x, x).real  # TODO: optimize?!
              if norm_squared < 0:
                  norm_squared = 0.0  # Compensate for numerical error
              return float(np.sqrt(norm_squared))
          else:
              return float(_pnorm_diagweight(x, self.exponent, self.array))
docs: Return the weighted norm of ``x``.
  
          Parameters
          ----------
          x : `NumpyTensor`
              Tensor whose norm is calculated.
  
          Returns
          -------
          norm : float
              The norm of the provided tensor.