How to save groovy output to pipeline variable
Have you tried setting returnStdout to true in the sh() command per the Jenkins documentation?

You can then assign that output to a variable within your pipeline:

def artifactsList = sh(label: 'Running amd_distribution_input transformation', returnStdout: true, script: 'python amd_distribution_input_transformation.py')


and check what kind of object that variable is, and act on it accordinly

echo(artifactsList.getClass())