code: def add_params_from_parameter_sharding(
      fused_params: Optional[Dict[str, Any]],
      parameter_sharding: ParameterSharding,
  ) -> Dict[str, Any]:
      """
      Extract params from parameter sharding and then add them to fused_params.
  
      Params from parameter sharding will override the ones in fused_params if they
      exist already.
  
      Args:
          fused_params (Optional[Dict[str, Any]]): the existing fused_params
          parameter_sharding (ParameterSharding): the parameter sharding to use
  
      Returns:
          [Dict[str, Any]]: the fused_params dictionary with params from parameter
          sharding added.
  
      """
      if fused_params is None:
          fused_params = {}
  
      # update fused_params using params from parameter_sharding
      # this will take precidence over the fused_params provided from sharders
      if parameter_sharding.cache_params is not None:
          cache_params = parameter_sharding.cache_params
          if cache_params.algorithm is not None:
              fused_params["cache_algorithm"] = cache_params.algorithm
          if cache_params.load_factor is not None:
              fused_params[
                  "cache_load_factor"
              ] = cache_params.load_factor
          if cache_params.reserved_memory is not None:
              fused_params[
                  "cache_reserved_memory"
              ] = cache_params.reserved_memory
          if cache_params.precision is not None:
              fused_params["cache_precision"] = cache_params.precision
          if cache_params.prefetch_pipeline is not None:
              fused_params[
                  "prefetch_pipeline"
              ] = cache_params.prefetch_pipeline
  
      if parameter_sharding.enforce_hbm is not None:
          fused_params["enforce_hbm"] = parameter_sharding.enforce_hbm
  
      if parameter_sharding.stochastic_rounding is not None:
          fused_params[
              "stochastic_rounding"
          ] = parameter_sharding.stochastic_rounding
  
      if parameter_sharding.bounds_check_mode is not None:
          fused_params[
              "bounds_check_mode"
          ] = parameter_sharding.bounds_check_mode
  
      # print warning if sharding_type is data_parallel or kernel is dense
      if (
          parameter_sharding.sharding_type
          == ShardingType.DATA_PARALLEL.value
      ):
          logger.warning(
              f"Sharding Type is {parameter_sharding.sharding_type}, "
              "caching params will be ignored"
          )
      elif (
          parameter_sharding.compute_kernel
          == EmbeddingComputeKernel.DENSE.value
      ):
          logger.warning(
              f"Compute Kernel is {parameter_sharding.compute_kernel}, "
              "caching params will be ignored"
          )
  
      return fused_params
  
imports: import copy
  import logging
  from collections import OrderedDict
  from itertools import accumulate
  from typing import Any, Dict, List, Optional, Set, Type, TypeVar, Union
  import torch
  from fbgemm_gpu.split_embedding_configs import EmbOptimType
  from torch import nn
  from torchrec import optim
  from torchrec.distributed.embedding_types import EmbeddingComputeKernel
  from torchrec.distributed.types import DataType, ParameterSharding, ShardedModule, ShardingType
  from torchrec.modules.embedding_configs import data_type_to_sparse_type
  from torchrec.types import CopyMixIn
label_desc: Use image node_id 10 for calling a global function with example usage: add_params_from_parameter_sharding(fused_params, parameter_sharding) and returns: fused_params