code: def write_biom(biomT, output_fp, fmt="hdf5", gzip=False):
      
      opener = open
      mode = 'w'
      if gzip and fmt != "hdf5":
          if not output_fp.endswith(".gz"):
              output_fp += ".gz"
          opener = gzip_open
          mode = 'wt'
  
      # HDF5 BIOM files are gzipped by default
      if fmt == "hdf5":
          opener = h5py.File
  
      with opener(output_fp, mode) as biom_f:
          if fmt == "json":
              biomT.to_json(biomT.generated_by, direct_io=biom_f)
          elif fmt == "tsv":
              biom_f.write(biomT.to_tsv())
          else:
              biomT.to_hdf5(biom_f, biomT.generated_by)
  
      return output_fp
docs: Write the BIOM table to a file.
  
      :type biomT: biom.table.Table
      :param biomT: A BIOM table containing the per-sample OTU counts and metadata
                    to be written out to file.
      :type output_fp str
      :param output_fp: Path to the BIOM-format file that will be written.
      :type fmt: str
      :param fmt: One of: hdf5, json, tsv. The BIOM version the table will be
                  output (2.x, 1.0, 'classic').