code: def update_module_params(module, new_params):  # noqa: D202
      """Load parameters to a module.
  
      This function acts like `torch.nn.Module._load_from_state_dict()`, but
      it replaces the tensors in module with those in new_params, while
      `_load_from_state_dict()` loads only the value. Use this function so
      that the `grad` and `grad_fn` of `new_params` can be restored
  
      Args:
          module (torch.nn.Module): A torch module.
          new_params (dict): A dict of torch tensor used as the new
              parameters of this module. This parameters dict should be
              generated by `torch.nn.Module.named_parameters()`
  
      """
      named_modules = dict(module.named_modules())
  
      # pylint: disable=protected-access
      def update(m, name, param):
          del m._parameters[name]  # noqa: E501
          setattr(m, name, param)
          m._parameters[name] = param  # noqa: E501
  
      for name, new_param in new_params.items():
          if "." in name:
              module_name, param_name = tuple(name.rsplit(".", 1))
              if module_name in named_modules:
                  update(
                      named_modules[module_name], param_name, new_param
                  )
          else:
              update(module, name, new_param)
  
imports: import copy
  import math
  import warnings
  import torch
  from torch import nn
  import torch.nn.functional
label_desc: Use image node_id 11 for calling a global function with example usage: update_module_params(module, new_params) without return types