<｜begin▁of▁sentence｜>### Instruction:
Given the High-energy theory collaborations Graph which you can read from a GML file named hep-th.gml, can you use both Louvain and Leiden algorithms in cdlib to perform community detection? And can you compute the average F1 score of the optimal algorithm matches between the partitions detected by these algorithms?

Notes: You need to print the F1 score.
### Response:
import networkx as nx
from cdlib import algorithms, evaluation

# Load a graph of high-energy theory collaborations
G = nx.read_gml('hep-th.gml')

# Perform community detection using two different algorithms
louvain_communities = algorithms.louvain(G)
leiden_communities = algorithms.leiden(G)

# Compute the average F1 score of the optimal algorithm matches between the communities detected
f1_score = evaluation.f1(louvain_communities, leiden_communities)
print(f1_score.score)
<|EOT|>
