def ListPlugins(logdir):
    """List all the plugins that have registered assets in logdir.

    If the plugins_dir does not exist, it returns an empty list. This maintains
    compatibility with old directories that have no plugins written.

    Args:
      logdir: A directory that was created by a TensorFlow events writer.

    Returns:
      a list of plugin names, as strings
    """
    plugins_dir = os.path.join(logdir, _PLUGINS_DIR)
    try:
        entries = tf.io.gfile.listdir(plugins_dir)
    except tf.errors.NotFoundError:
        return []
    # Strip trailing slashes, which listdir() includes for some filesystems
    # for subdirectories, after using them to bypass IsDirectory().
    return [
        x.rstrip("/")
        for x in entries
        if x.endswith("/") or _IsDirectory(plugins_dir, x)
    ]