Weighted standard deviation of list of tensors

Hi, I have implementation of weighted std in NumPy as:

def weighted_std(average_of_tensor_list, list_of_tensors, list_num_samples):
     list_of_tensors_new = np.array([(list_of_tensors[i] - average_of_tensor_list)**2 for i in range(len(list_of_tensors))], dtype="object")
     variance = np.average(list_of_tensors_new, weights=list_num_samples, axis=0)
     std = np.array([np.sqrt(variance[i]) for i in range(len(variance))], dtype="object")
     return std

I am trying to convert this into equivalent PyTorch code, can anyone please guide, what should be the way?