code: def add_all_transport_reactions(model, boundaries, allow_duplicates=False):
      
  
      all_reactions = {}
      if not allow_duplicates:
          # TODO: Avoid adding reactions that already exist in the database.
          # This should be integrated in the database.
          for rxnid in model.database.reactions:
              rx = model.database.get_reaction(rxnid)
              all_reactions[rx] = rxnid
  
      boundary_pairs = set()
      for source, dest in boundaries:
          if source != dest:
              boundary_pairs.add(tuple(sorted((source, dest))))
  
      added = set()
      added_pairs = set()
      initial_compounds = set(model.compounds)
      reactions = set(model.database.reactions)
      for compound in initial_compounds:
          for c1, c2 in boundary_pairs:
              compound1 = compound.in_compartment(c1)
              compound2 = compound.in_compartment(c2)
              pair = compound1, compound2
              if pair in added_pairs:
                  continue
  
              rxnid_tp = create_transport_id(reactions, compound1, compound2)
  
              reaction_tp = Reaction(Direction.Both, {
                  compound1: -1,
                  compound2: 1
              })
              if reaction_tp not in all_reactions:
                  model.database.set_reaction(rxnid_tp, reaction_tp)
                  reactions.add(rxnid_tp)
              else:
                  rxnid_tp = all_reactions[reaction_tp]
  
              if not model.has_reaction(rxnid_tp):
                  added.add(rxnid_tp)
              model.add_reaction(rxnid_tp)
              added_pairs.add(pair)
  
      return added
docs: Add all transport reactions to database and to model.
  
      Add transport reactions for all boundaries. Boundaries are defined
      by pairs (2-tuples) of compartment IDs. Transport reactions are
      added for all compounds in the model, not just for compounds in the
      two boundary compartments.
  
      Args:
          model: :class:`psamm.metabolicmodel.MetabolicModel`.
          boundaries: Set of compartment boundary pairs.
  
      Returns:
          Set of IDs of reactions that were added.