code: def _factor_lhs(self, out_port):
          
          n = self.cdim
          assert (0 <= out_port < n)
          out_inv = self.permutation.index(out_port)
  
          # (I) is equivalent to
          #       m_{out_port -> (n-1)} <<  self << m_{(n-1)
          #           -> out_inv} == (red_self + cid(1))     (I')
  
          red_self_plus_cid1 = (map_channels({out_port: (n - 1)}, n) <<
                                self <<
                                map_channels({(n - 1): out_inv}, n))
  
          if isinstance(red_self_plus_cid1, CPermutation):
  
              #make sure we can factor
              assert red_self_plus_cid1.permutation[(n - 1)] == (n - 1)
  
              #form reduced permutation object
              red_self = CPermutation.create(red_self_plus_cid1.permutation[:-1])
  
              return out_inv, red_self
          else:
              # 'red_self_plus_cid1' must be the identity for n channels.
              # Actually, this case can only occur
              # when self == m_{in_port ->  in_im}
  
              return out_inv, circuit_identity(n - 1)
docs: With::
  
              n           := self.cdim
              out_inv     := invert_permutation(self.permutation)[out_port]
              m_{k->l}    := map_signals_circuit({k:l}, n)
  
          solve the equation (I) containing ``self``::
  
              m_{out_port -> (n-1)} << self
                  == (red_self + cid(1)) << m_{out_inv -> (n-1)}           (I)
  
          for the (n-1) channel CPermutation ``red_self``.
          Return out_inv, red_self.
  
          This is useful when 'self' is the LHS in a SeriesProduct Object that is
          within a Feedback loop as it allows to extract the feedback channel
          from the permutation and moving the remaining part of the permutation
          (``red_self``) outside of the feedback loop.