How to check if a source pad is linked to a sink pad in deepstream python?

Hi, I have some following questions:

  1. How can I check if a source pad is linked to a sink pad in deepstream python ?

  2. I want to replace the nvanalytics element that already linked with the new one as shown in the figure below. How can I do this ?

Could you guys help me with these questions ? Thanks in advance !

You can check all API in below.

https://lazka.github.io/pgi-docs/Gst-1.0/classes/Pad.html#Gst.Pad.is_linked