code: def svg2str(display_object, dpi=300):
      
      from io import StringIO
      image_buf = StringIO()
      display_object.frame_axes.figure.savefig(
          image_buf, dpi=dpi, format='svg',
          facecolor='k', edgecolor='k')
      return image_buf.getvalue()
docs: Serializes a nilearn display object as a string