How to define a mesh in colab as the one imported?

You need to use the XDMFFile to read the mesh:

mesh = Mesh()
with XDMFFile("perfect_contact.xdmf") as infile:
     infile.read(mesh)

which reads the mesh data into the mesh variable