Implement a custom loss function in PyTorch that penalizes model complexity as well as prediction error.
Return the scalar mean squared error plus complexity_weight times the sum of squared values across all parameter tensors. Implement the equivalent calculation using nested Python lists so JSON test inputs can be evaluated; the function signature is custom_loss(predictions, targets, parameters, complexity_weight). For example, predictions [1, 2], targets [0, 4], parameters [[1, -2], [0.5]], and weight 0.1 produce 3.025. Inputs contain matching prediction and target shapes, and the complexity weight is nonnegative.
def custom_loss(predictions, targets, parameters, complexity_weight):