code: def rebalance(self):
          
  
          # Compute norms along columns for each factor matrix
          norms = [sci.linalg.norm(f, axis=0) for f in self.factors]
  
          # Multiply norms across all modes
          lam = sci.multiply.reduce(norms) ** (1/self.ndim)
  
          # Update factors
          self.factors = [f * (lam / fn) for f, fn in zip(self.factors, norms)]
          return self
docs: Rescales factors across modes so that all norms match.