code: def guard_retract(worksheet):
      
      analyses = worksheet.getAnalyses()
      detached = ['rejected', 'retracted']
      num_detached = 0
      for analysis in analyses:
          if api.get_workflow_status_of(analysis) in detached:
              num_detached += 1
          elif not isTransitionAllowed(analysis, "retract"):
              return False
      return analyses and num_detached < len(analyses) or False
docs: Return whether the transition retract can be performed or not to the
      worksheet passed in. Since the retract transition from worksheet is a
      shortcut to retract transitions from all analyses the worksheet contains,
      this guard only returns True if retract transition is allowed for all
      analyses the worksheet contains