class_docstr: Create a hook that will add the given keys/values in the state dict metadata of the module it is registered on
  Args:
      extra_metadata: the extra state dict to be added to the state dict
      allow_overwrite: If True, do not raise if any of the keys are already in the state dict
        and would be overwritten by the new state
code: def __call__(
      self,
      module: torch.nn.Module,
      destination: Dict[str, torch.Tensor],
      prefix: str,
      local_metadata: Dict[str, Any],
  ) -> Dict[str, torch.Tensor]:
      for key, value in self.extra_metadata.items():
          if key in local_metadata and not self.allow_overwrite:
              raise ValueError(
                  f"Metadata key '{key}' would be overwritten as it already exists in the local_metadata dict: {local_metadata[key]}"
              )
          local_metadata[key] = value
      return destination
  
file_path: coremltools/coremltools/optimize/torch/_utils/state_dict_utils.py
imports: from typing import Any, Dict, Mapping, NamedTuple
  import torch
label_desc: Use image node_id 2 for calling the AddMetadataStateDictHook obj's underlying member method code with example usage: obj.__call__(module, destination, prefix, local_metadata) and returns: destination