code: def add_rule_to_model(model, rule, annotations=None):
      
      try:
          model.add_component(rule)
          # If the rule was actually added, also add the annotations
          if annotations:
              model.annotations += annotations
      # If this rule is already in the model, issue a warning and continue
      except ComponentDuplicateNameError:
          msg = "Rule %s already in model! Skipping." % rule.name
          logger.debug(msg)
docs: Add a Rule to a PySB model and handle duplicate component errors.