code: def average_params(params_list):
      assert isinstance(params_list, (tuple, list, collections.deque))
      n = len(params_list)
      if n == 1:
          return params_list[0]
      new_params = collections.OrderedDict()
      keys = None
      for i, params in enumerate(params_list):
          if keys is None:
              keys = params.keys()
          for k, v in params.items():
              if k not in keys:
                  raise ValueError(
                      "the %d-th model has different params" % i
                  )
              if k not in new_params:
                  new_params[k] = v / n
              else:
                  new_params[k] += v / n
      return new_params
  
imports: import os
  import copy
  import math
  import json
  import collections
  import numpy
  import pandas
  import torch
  import torch.nn
  import torch.optim
  import torch.nn.functional
  from tqdm import tqdm
  from qlib.utils import get_or_create_path
  from qlib.log import get_module_logger
  from qlib.model.base import Model
label_desc: Use image node_id 2 for calling a global function with example usage: average_params(params_list) and returns: new_params, params_list