code: def format_variable_map(variable_map, join_lines=True):
    
    rows = []
    rows.append(("Key", "Variable", "Shape", "Type", "Collections", "Device"))
    var_to_collections = _get_vars_to_collections(variable_map)
  
    sort_key = lambda item: (item[0], item[1].name)
    for key, var in sorted(variable_map_items(variable_map), key=sort_key):
      shape = "x".join(str(dim) for dim in var.get_shape().as_list())
      dtype = repr(var.dtype.base_dtype).replace("tf.", "")
      coll = ", ".join(sorted(var_to_collections[var]))
      rows.append((key, var.op.name, shape, dtype, coll, _format_device(var)))
    return _format_table(rows, join_lines)
docs: Takes a key-to-variable map and formats it as a table.