code: def permute(self, idx):
          
  
          # Check that input is a true permutation
          if set(idx) != set(range(self.rank)):
              raise ValueError('Invalid permutation specified.')
  
          # Update factors
          self.factors = [f[:, idx] for f in self.factors]
          return self.factors
docs: Permutes the columns of the factor matrices inplace