docstr: For each module in the graph, we want to calculate the expected
  scaled weight and bias values. This only works for models containing
  single or connected linear layers.
docstr_tok: ["For","each","module","in","the","graph",",","we","want","to","calculate","the","expected","scaled","weight","and","bias","values",".","This","only","works","for","models","containing","single","or","connected","linear","layers","."]
code: def get_expected_weights_bias(self, model, x, exp_eq_scales):
      """For each module in the graph, we want to calculate the expected
      scaled weight and bias values. This only works for models containing
      single or connected linear layers.
      """
      exp_weights = []
      exp_bias = []
      for i, (_, module) in enumerate(model.named_children()):
          weight = module.weight.detach().numpy()
          bias = module.bias.detach().numpy()
  
          scaled_weight = weight * np.reciprocal(exp_eq_scales[i])
          scaled_bias = bias
          if i + 1 < len(exp_eq_scales):
              scaled_weight = (scaled_weight.T * exp_eq_scales[i + 1]).T
              scaled_bias = (scaled_bias.T * exp_eq_scales[i + 1]).T
  
          exp_weights.append(scaled_weight)
          exp_bias.append(scaled_bias)
  
          x = x @ weight.T + bias
  
      return exp_weights, exp_bias
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  import torch.ao.nn.intrinsic.quantized
  import torch.ao.nn.quantized
  from torch.ao.quantization import default_qconfig
  from torch.ao.quantization.observer import MinMaxObserver, PerChannelMinMaxObserver
  from torch.ao.quantization.quantize_fx import prepare_fx, convert_fx
  from torch.ao.quantization.fx._equalize import _InputEqualizationObserver, _WeightEqualizationObserver, calculate_equalization_scale, default_equalization_qconfig, _convert_equalization_ref, get_layer_sqnr_dict, get_equalization_qconfig_dict
  from torch.testing._internal.common_quantization import NodeSpec, QuantizationTestCase, SingleLayerLinearModel, TwoLayerLinearModel, LinearAddModel, SingleLayerFunctionalLinearModel, TwoLayerFunctionalLinearModel, FunctionalLinearAddModel, ConvModel, TwoLayerConvModel, SingleLayerFunctionalConvModel, TwoLayerFunctionalConvModel, skipIfNoFBGEMM, LinearReluModel, LinearReluLinearModel, LinearReluAddModel, FunctionalLinearReluModel, FunctionalLinearReluLinearModel, ConvReluModel, ConvReluConvModel, ConvReluAddModel, FunctionalConvReluModel, FunctionalConvReluConvModel
  import copy
  import numpy
  from hypothesis import given
  from hypothesis import strategies
label_desc: Use image node_id 9 for calling the TestEqualizeFx obj's underlying member method code with example usage: obj.get_expected_weights_bias(model, x, exp_eq_scales) and returns: exp_weights,  exp_bias