code: public static <K, V> ImmutableListMultimap<K, V> copyOf(
        Multimap<? extends K, ? extends V> multimap) {
      if (multimap.isEmpty()) {
        return of();
      }
  
      // TODO(user): copy ImmutableSetMultimap by using asList() on the sets
      if (multimap instanceof ImmutableListMultimap) {
        @SuppressWarnings("unchecked") // safe since multimap is not writable
        ImmutableListMultimap<K, V> kvMultimap
            = (ImmutableListMultimap<K, V>) multimap;
        if (!kvMultimap.isPartialView()) {
          return kvMultimap;
        }
      }
  
      ImmutableMap.Builder<K, ImmutableList<V>> builder =
          new ImmutableMap.Builder<K, ImmutableList<V>>(multimap.asMap().size());
      int size = 0;
  
      for (Entry<? extends K, ? extends Collection<? extends V>> entry
          : multimap.asMap().entrySet()) {
        ImmutableList<V> list = ImmutableList.copyOf(entry.getValue());
        if (!list.isEmpty()) {
          builder.put(entry.getKey(), list);
          size += list.size();
        }
      }
  
      return new ImmutableListMultimap<K, V>(builder.build(), size);
    }
docs: Returns an immutable multimap containing the same mappings as {@code
  multimap}. The generated multimap's key and value orderings correspond to
  the iteration ordering of the {@code multimap.asMap()} view.
  
  <p>Despite the method name, this method attempts to avoid actually copying
  the data when it is safe to do so. The exact circumstances under which a
  copy will or will not be performed are undocumented and subject to change.
  
  @throws NullPointerException if any key or value in {@code multimap} is
  null