I modified the functions as below.
def load_params(avg_param):
    for p, avg_p in zip(model.parameters(), avg_param):
        p.data = deepcopy(avg_p)

  def flatten_params():
    flatten = deepcopy(list(p.data for p in model.parameters()))
    return flatten

def load_params(flattened):
    for p, avg_p in zip(model.parameters(), flattened):
        p.data = deepcopy(avg_p)

Currently, it works without error.
But, I am not sure it works as I intended.