code: def get_var_maybe_avg(namespace, var_name, training, polyak_decay):
      """utility for retrieving polyak averaged params
      Update average
      """
      v = getattr(namespace, var_name)
      v_avg = getattr(namespace, var_name + "_avg")
      v_avg -= (1 - polyak_decay) * (v_avg - v.data)
  
      if training:
          return v
      else:
          return v_avg
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn import Parameter
label_desc: Use image node_id 1 for calling a global function with example usage: get_var_maybe_avg(namespace, var_name, training, polyak_decay) and returns: v, v_avg