def encode_metadata(model, params, metadata):
  """Encodes metadata embeddings.

  Args:
    model: a NerfModel.
    params: the parameters of the model.
    metadata: the metadata dict.

  Returns:
    A new metadata dict with the encoded embeddings.
  """
  encoded_metadata = {}
  if model.use_nerf_embed:
    encoded_metadata['encoded_nerf'] = model.apply(
        {'params': params}, metadata, method=model.encode_nerf_embed)
  if model.use_warp:
    encoded_metadata['encoded_warp'] = model.apply(
        {'params': params}, metadata, method=model.encode_warp_embed)
  if model.has_hyper_embed:
    encoded_metadata['encoded_hyper'] = model.apply(
        {'params': params}, metadata, method=model.encode_hyper_embed)
  return encoded_metadata