code: def rebind_invalidated_ars(portal):
      
      logger.info("Rebinding retracted/invalidated ARs")
  
      # Walk through the Analysis Requests that were generated because of an
      # invalidation, get the source AR and rebind the fields
      relationship = "AnalysisRequestChildAnalysisRequest"
      ref_catalog = api.get_tool(REFERENCE_CATALOG)
      retests = ref_catalog(relationship=relationship)
      total = len(retests)
      to_remove = list()
      num = 0
      for num, relation in enumerate(retests, start=1):
          relation = relation.getObject()
          if not relation:
              continue
          retest = relation.getTargetObject()
          invalidated = relation.getSourceObject()
          retest.setInvalidated(invalidated)
          # Set ParentAnalysisRequest field to None, cause we will use this field
          # for storing Primary-Partitions relationship.
          retest.setParentAnalysisRequest(None)
  
          # Remove the relationship!
          to_remove.append((relation.aq_parent, relation.id))
  
          if num % 100 == 0:
              logger.info("Rebinding invalidated ARs: {0}/{1}"
                          .format(num, total))
  
      # Remove relationships
      for relation_to_remove in to_remove:
          folder = relation_to_remove[0]
          rel_id = relation_to_remove[1]
          folder.manage_delObjects([rel_id])
  
      logger.info("Rebound {} invalidated ARs".format(num))
docs: Rebind the ARs automatically generated because of the retraction of their
      parent to the new field 'Invalidated'. The field used until now
      'ParentAnalysisRequest' will be used for partitioning