code: def _write_bond_information(gsd_file, structure):
      
  
      gsd_file.bonds.N = len(structure.bonds)
  
      unique_bond_types = set()
      for bond in structure.bonds:
          t1, t2 = bond.atom1.type, bond.atom2.type
          if t1 == '' or t2 == '':
              t1, t2 = bond.atom1.name, bond.atom2.name
          t1, t2 = sorted([t1, t2], key=natural_sort)
          try:
              bond_type = ('-'.join((t1, t2)))
          except AttributeError: # no forcefield applied, bond.type is None
              bond_type = ('-'.join((t1, t2)), 0.0, 0.0)
          unique_bond_types.add(bond_type)
      unique_bond_types = sorted(list(unique_bond_types), key=natural_sort)
      gsd_file.bonds.types = unique_bond_types
  
      bond_typeids = []
      bond_groups = []
      for bond in structure.bonds:
          t1, t2 = bond.atom1.type, bond.atom2.type
          if t1 == '' or t2 == '':
              t1, t2 = bond.atom1.name, bond.atom2.name
          t1, t2 = sorted([t1, t2], key=natural_sort)
          try:
              bond_type = ('-'.join((t1, t2)))
          except AttributeError: # no forcefield applied, bond.type is None
              bond_type = ('-'.join((t1, t2)), 0.0, 0.0)
          bond_typeids.append(unique_bond_types.index(bond_type))
          bond_groups.append((bond.atom1.idx, bond.atom2.idx))
  
      gsd_file.bonds.typeid = bond_typeids
      gsd_file.bonds.group = bond_groups
docs: Write the bonds in the system.
  
      Parameters
      ----------
      gsd_file :
          The file object of the GSD file being written
      structure : parmed.Structure
          Parmed structure object holding system information