code: def canonical_dataset_to_grib(dataset, path, mode='wb', no_warn=False, grib_keys={}, **kwargs):
      # type: (xr.Dataset, str, str, bool, T.Dict[str, T.Any] T.Any) -> None
      
      if not no_warn:
          warnings.warn("GRIB write support is experimental, DO NOT RELY ON IT!", FutureWarning)
  
      # validate Dataset keys, DataArray names, and attr keys/values
      xr.backends.api._validate_dataset_names(dataset)
      xr.backends.api._validate_attrs(dataset)
  
      real_grib_keys = {k[5:]: v for k, v in dataset.attrs.items() if k[:5] == 'GRIB_'}
      real_grib_keys.update(grib_keys)
  
      with open(path, mode=mode) as file:
          for data_var in dataset.data_vars.values():
              canonical_dataarray_to_grib(data_var, file, grib_keys=real_grib_keys, **kwargs)
docs: Write a ``xr.Dataset`` in *canonical* form to a GRIB file.