[MPS] Fix the index error in constant_pad_nd() with single-dimension input (#83745)

* Fix the index error in constant_pad_nd() with single-dimension input (#83343)
- Also added a test case in test_mps for it

* Move padding code into new file Pad.mm

Fixes https://github.com/pytorch/pytorch/issues/83343

Pull Request resolved: https://github.com/pytorch/pytorch/pull/83745
Approved by: https://github.com/razarmehr
diff --git a/test/test_mps.py b/test/test_mps.py
index 271a617..828b762 100644
--- a/test/test_mps.py
+++ b/test/test_mps.py
@@ -3491,6 +3491,8 @@
         helper((2, 1, 6), 3, nn.ReplicationPad1d)
         # Constant Pad 1D
         helper((2, 3, 4), 2, nn.ConstantPad1d)
+        # Constant Pad 1D with single dimension input
+        helper((16), (1, 2), nn.ConstantPad1d)
 
         # 2D Padding
         helper((1, 2, 3, 4), (1, 1, 2, 0), nn.ReflectionPad2d)