function transpose(map) {
  const /** !Map<V,K> */ transposed = new Map();
  for (const key of map.keys()) {
    const val = map.get(key);
    transposed.set(val, key);
  }
  return transposed;
}
Returns a new ES6 Map in which all the keys and values from the
given map are interchanged (keys become values and values become keys). If
multiple keys in the given map to the same value, the resulting value in the
transposed map is implementation-dependent.

It acts very similarly to {goog.object.transpose(Object)}.
@param {!MapLike<K,V>} map The map to transpose.
@return {!Map<V,K>} A transposed version of the given map.
@template K,V