Torch operation on nn.Parameter

I have a list of parameters and I would like to sum all the elements in the list

import torch
from torch import nn

a = nn.Parameter(torch.rand(1))
b = nn.Parameter(torch.rand(1))

my_list = [a, b]
torch.sum(*my_list)

I receive the error

Traceback (most recent call last):
  File "<input>", line 8, in <module>
TypeError: sum() received an invalid combination of arguments - got (Parameter, Parameter), but expected one of:
 * (Tensor input, *, torch.dtype dtype)
 * (Tensor input, tuple of ints dim, bool keepdim, *, torch.dtype dtype, Tensor out)
 * (Tensor input, tuple of names dim, bool keepdim, *, torch.dtype dtype, Tensor out)

I was wondering if there is a way to perform operations like torch.sum on Parameters?

I think you confused the Op torch.sum with torch.add.

torch.sum: (*input* , *** , *dtype=None* ) → [Tensor]
Returns the sum of all elements in the input tensor.
Docs: torch.sum — PyTorch 1.11.0 documentation

torch. add: (*input*, *other*, ***, *alpha=1*, *out=None* ) → [Tensor]
Adds other, scaled by alpha, to input.
Docs: torch.add — PyTorch 1.11.0 documentation

It works if you do:

import torch
from torch import nn

a = nn.Parameter(torch.rand(1))
b = nn.Parameter(torch.rand(1))

my_list = [a, b]

a = torch.add(*my_list)