code: def replace_complexes(self, linked_stmts=None):
          
          if linked_stmts is None:
              linked_stmts = self.infer_complexes(self.statements)
          new_stmts = []
          for stmt in self.statements:
              if not isinstance(stmt, Complex):
                  new_stmts.append(stmt)
                  continue
              found = False
              for linked_stmt in linked_stmts:
                  if linked_stmt.refinement_of(stmt, hierarchies):
                      found = True
              if not found:
                  new_stmts.append(stmt)
              else:
                  logger.info('Removing complex: %s' % stmt)
          self.statements = new_stmts
docs: Remove Complex Statements that can be inferred out.
  
          This function iterates over self.statements and looks for Complex
          Statements that either match or are refined by inferred Complex
          Statements that were linked (provided as the linked_stmts argument).
          It removes Complex Statements from self.statements that can be
          explained by the linked statements.
  
          Parameters
          ----------
          linked_stmts : Optional[list[indra.mechlinker.LinkedStatement]]
              A list of linked statements, optionally passed from outside.
              If None is passed, the MechLinker runs self.infer_complexes to
              infer Complexes and obtain a list of LinkedStatements that are
              then used for removing existing Complexes in self.statements.