class_docstr: SockeyeModel shares components needed for both training and inference.
  The main components of a Sockeye model are
  1) Source embedding
  2) Target embedding
  3) Encoder
  4) Decoder
  5) Output Layer
  
  ModelConfig contains parameters and their values that are fixed at training time and must be re-used at inference
  time.
  
  :param config: Model configuration.
  :param inference_only: Use the model only for inference, enabling optimizations.
  :param clamp_to_dtype: Avoid -inf/inf by clamping outputs to min/max finite values for their dtype.
class_docstr_tok: ["SockeyeModel","shares","components","needed","for","both","training","and","inference",".","The","main","components","of","a","Sockeye","model","are","1",")","Source","embedding","2",")","Target","embedding","3",")","Encoder","4",")","Decoder","5",")","Output","Layer","ModelConfig","contains","parameters","and","their","values","that","are","fixed","at","training","time","and","must","be","re-used","at","inference","time",".",":","param","config",":","Model","configuration",".",":","param","inference_only",":","Use","the","model","only","for","inference",",","enabling","optimizations",".",":","param","clamp_to_dtype",":","Avoid","-inf\/inf","by","clamping","outputs","to","min\/max","finite","values","for","their","dtype","."]
docstr: Update model params with new values from a dictionary.
  
  :param new_params: Dictionary containing the new parameters.
  :param allow_missing: Whether to skip setting parameters not represented in the dictionary.
  :param ignore_extra: Whether to ignore parameters from new_params that are not present in this model.
docstr_tok: ["Update","model","params","with","new","values","from","a","dictionary",".",":","param","new_params",":","Dictionary","containing","the","new","parameters",".",":","param","allow_missing",":","Whether","to","skip","setting","parameters","not","represented","in","the","dictionary",".",":","param","ignore_extra",":","Whether","to","ignore","parameters","from","new_params","that","are","not","present","in","this","model","."]
code: def set_parameters(
      self,
      new_params: Dict[str, pt.nn.Parameter],
      allow_missing: bool = True,
      ignore_extra: bool = False,
  ):
      """
      Update model params with new values from a dictionary.
  
      :param new_params: Dictionary containing the new parameters.
      :param allow_missing: Whether to skip setting parameters not represented in the dictionary.
      :param ignore_extra: Whether to ignore parameters from new_params that are not present in this model.
      """
      model_params = dict(self.named_parameters())
      if not allow_missing:
          for name, _ in model_params.items():
              assert name in new_params.keys(), (
                  "Parameter '%s' is missing in new_params dictionary. "
                  "Set allow_missing=True to ignore missing parameters."
                  % name
              )
      for name in new_params:
          if not ignore_extra and name not in model_params:
              raise ValueError(
                  "Parameter '%s' in new_params dictionary is not present in ParameterDict. "
                  "Set ignore_extra=True to ignore." % name
              )
          if name in model_params:
              assert (
                  model_params[name].size() == new_params[name].size()
              ), (
                  "Parameter '%s' has shape '%s' in the model but shape '%s' in the new_params dictionary."
                  % (
                      name,
                      model_params[name].size(),
                      new_params[name].size(),
                  )
              )
              model_params[name].data[:] = new_params[name].data
  
imports: import copy
  import logging
  import os
  import time
  from dataclasses import dataclass
  from functools import lru_cache
  from typing import cast, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from sockeye import __version__
  from .None import constants
  from .None import data_io
  from .None import decoder
  from .None import encoder
  from .None import layers
  from .None import transformer
  from .None import utils
  from .None import vocab
  from .config import Config
  from .encoder import FactorConfig
  from .layers import LengthRatioConfig
  from .None import nvs
  from sockeye.knn import KNNConfig
label_desc: Use image node_id 16 for calling the SockeyeModel obj's underlying member method code with example usage: obj.set_parameters(new_params, allow_missing, ignore_extra) without return types