code: def generate_bonds(self, name_a, name_b, dmin, dmax):
          
          particle_kdtree = PeriodicCKDTree(
              data=self.xyz, bounds=self.periodicity)
          particle_array = np.array(list(self.particles()))
          added_bonds = list()
          for p1 in self.particles_by_name(name_a):
              nearest = self.particles_in_range(p1, dmax, max_particles=20,
                                                particle_kdtree=particle_kdtree,
                                                particle_array=particle_array)
              for p2 in nearest:
                  if p2 == p1:
                      continue
                  bond_tuple = (p1, p2) if id(p1) < id(p2) else (p2, p1)
                  if bond_tuple in added_bonds:
                      continue
                  min_dist = self.min_periodic_distance(p2.pos, p1.pos)
                  if (p2.name == name_b) and (dmin <= min_dist <= dmax):
                      self.add_bond((p1, p2))
                      added_bonds.append(bond_tuple)
docs: Add Bonds between all pairs of types a/b within [dmin, dmax].
  
          Parameters
          ----------
          name_a : str
              The name of one of the Particles to be in each bond
          name_b : str
              The name of the other Particle to be in each bond
          dmin : float
              The minimum distance between Particles for considering a bond
          dmax : float
              The maximum distance between Particles for considering a bond