code: def _add_module_to_qconfig_obs_ctr(
      qconfig: QConfigAny, module: Optional[nn.Module]
  ) -> Any:
      r"""This is a helper function for use in quantization prepare that updates a qconfig so that
      the constructors stored in the qconfig will create observers on the same device that
      'module' is on. This is intended to be used when the qconfigs are propagated to each
      module in order to avoid potential device alignment issues.
  
      Args:
          qconfig: QConfig with obs constructors stored in activation and weight
          module: module which the qconfig is related to
  
      Return:
          qconfig: configured so that obs constructors set to construct on the same device as module
      """
  
      if (
          module is None
          or qconfig is None
          or qconfig._fields != ("activation", "weight")
      ):
          return qconfig
  
      def get_factory_kwargs_based_on_module_device():
          assert isinstance(module, torch.nn.Module)
          devices = {p.device for p in module.parameters()} | {
              p.device for p in module.buffers()
          }
          device = next(iter(devices)) if len(devices) > 0 else None
          return None if device is None else {"device": device}
  
      def configure_constructor_to_put_obs_on_module_device(
          original_constructor,
      ):
          try:
              # check if constructor can accept factory_kwargs
              check = original_constructor.with_args(
                  factory_kwargs=None
              )
              check()
              return original_constructor.with_callable_args(
                  factory_kwargs=get_factory_kwargs_based_on_module_device
              )
          except (
              AttributeError
          ):  # qconfig doesn't have activation or weight
              return original_constructor
          except (
              TypeError
          ):  # the class doesn't accept factory_kwargs argument
              return original_constructor
  
      activation = configure_constructor_to_put_obs_on_module_device(
          qconfig.activation
      )
      weight = configure_constructor_to_put_obs_on_module_device(
          qconfig.weight
      )
  
      return QConfig(activation, weight)
  
imports: from collections import namedtuple
  from typing import Optional, Any, Union, Type
  import torch
  import torch.nn
  from torch.ao.quantization.fake_quantize import FakeQuantize, FakeQuantizeBase, default_fake_quant, default_dynamic_fake_quant, default_per_channel_weight_fake_quant, default_weight_fake_quant, default_fused_act_fake_quant, default_fused_wt_fake_quant, FusedMovingAvgObsFakeQuantize, default_fused_per_channel_wt_fake_quant, default_embedding_fake_quant, default_embedding_fake_quant_4bit, fused_wt_fake_quant_range_neg_127_to_127, fused_per_channel_wt_fake_quant_range_neg_127_to_127
  from .observer import _PartialWrapper, MinMaxObserver, HistogramObserver, MovingAverageMinMaxObserver, NoopObserver, PlaceholderObserver, ReuseInputObserver, default_debug_observer, default_dynamic_quant_observer, default_float_qparams_observer, default_float_qparams_observer_4bit, default_observer, default_per_channel_weight_observer, default_placeholder_observer, default_weight_observer, weight_observer_range_neg_127_to_127, per_channel_weight_observer_range_neg_127_to_127, default_reuse_input_observer, ObserverBase
  import warnings
  import copy
label_desc: Use image node_id 6 for calling a global function with example usage: _add_module_to_qconfig_obs_ctr(qconfig, module) and returns: QConfig, qconfig, unknown, original_constructor, original_constructor, original_constructor