code: def write(cls, filename, samples, write_params=None, static_args=None,
                **metadata):
          
          with h5py.File(filename, 'w') as fp:
              # write metadata
              if static_args is None:
                  static_args = {}
              fp.attrs["static_args"] = static_args.keys()
              fp.attrs['injtype'] = cls.injtype
              for key, val in metadata.items():
                  fp.attrs[key] = val
              if write_params is None:
                  write_params = samples.fieldnames
              for arg, val in static_args.items():
                  fp.attrs[arg] = val
              for field in write_params:
                  fp[field] = samples[field]
docs: Writes the injection samples to the given hdf file.
  
          Parameters
          ----------
          filename : str
              The name of the file to write to.
          samples : io.FieldArray
              FieldArray of parameters.
          write_params : list, optional
              Only write the given parameter names. All given names must be keys
              in ``samples``. Default is to write all parameters in ``samples``.
          static_args : dict, optional
              Dictionary mapping static parameter names to values. These are
              written to the ``attrs``.
          \**metadata :
              All other keyword arguments will be written to the file's attrs.