<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tri_to_am(tri):
 r""" Given a Delaunay Triangulation object from Scipy's ``spatial`` module, converts to a sparse adjacency matrix network representation. Parameters tri : Delaunay Triangulation Object This object is produced by ``scipy.spatial.Delaunay`` Returns ------- A sparse adjacency matrix in COO format. The network is undirected and unweighted, so the adjacency matrix is upper-triangular and all the weights are set to 1. """

    # Create an empty list-of-list matrix
    lil = sprs.lil_matrix((tri.npoints, tri.npoints))
    # Scan through Delaunay triangulation to retrieve pairs
    indices, indptr = tri.vertex_neighbor_vertices
    for k in range(tri.npoints):
        lil.rows[k] = indptr[indices[k]:indices[k+1]]
    # Convert to coo format
    lil.data = lil.rows  # Just a dummy array to make things work properly
    coo = lil.tocoo()
    # Set weights to 1's
    coo.data = sp.ones_like(coo.data)
    # Remove diagonal, and convert to csr remove duplicates
    am = sp.sparse.triu(A=coo, k=1, format='csr')
    # The convert back to COO and return
    am = am.tocoo()
    return am