A transform node was expected and you passed a string instead. You don’t need to copy-paste code from modules but you can use module logic from another module or from the Python console. For example, this should do everything you need:
# Get input and output nodes
sourceModel = getNode('Segment_1')
targetModel = getNode('Segment_2')
sourceToTargetTransform = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLLinearTransformNode")
# Register
import ModelRegistration
mrLogic = ModelRegistration.ModelRegistrationLogic()
mrLogic.run(sourceModel, targetModel, sourceToTargetTransform)
# Show results
sourceModel.SetAndObserveTransformNodeID(sourceToTargetTransform.GetID())
sourceModel.GetDisplayNode().SetOpacity(0.5)
targetModel.GetDisplayNode().SetOpacity(0.5)
If you need non-linear (warping) registration of nodes then you can use SegmentRegistration extension.