Equivalent for tf.squared_difference

Is there a corresponding function for TensorFlow’s squared_difference in PyTorch? or should I just create a function

def squared_difference(input, target):
    return (input - target) ** 2

to define it? For the sake of completeness:

tf.math.squared_difference: Returns (x - y)(x - y) element-wise.

The squared_difference function that you have used should be adequate. Just looked at the forums. There seems to be nothing that explicitly computes what you are looking for.