code: def infer_activations(stmts):
          linked_stmts = []
          af_stmts = _get_statements_by_type(stmts, ActiveForm)
          mod_stmts = _get_statements_by_type(stmts, Modification)
          for af_stmt, mod_stmt in itertools.product(*(af_stmts, mod_stmts)):
              if mod_stmt.enz is None or \
                  (not af_stmt.agent.entity_matches(mod_stmt.sub)):
                  continue
              if not af_stmt.agent.mods:
                  continue
              found = False
              for mc in af_stmt.agent.mods:
                  if mc.mod_type == modclass_to_modtype[mod_stmt.__class__] and \
                      mc.residue == mod_stmt.residue and \
                      mc.position == mod_stmt.position:
                      found = True
              if not found:
                  continue
              ev = mod_stmt.evidence
              if af_stmt.is_active:
                  st = Activation(mod_stmt.enz, mod_stmt.sub, af_stmt.activity,
                                  evidence=ev)
              else:
                  st = Inhibition(mod_stmt.enz, mod_stmt.sub, af_stmt.activity,
                                  evidence=ev)
              linked_stmts.append(LinkedStatement([af_stmt, mod_stmt], st))
          return linked_stmts