code: def _create_proportional_tensor(axis_weights):
      # take the per-feature weights and distribute them proportionally to each cell in a tensor
  
      axis_sums = [weights.sum() for weights in axis_weights]
  
      # Normally you'd expect each axis to sum to the total weight from the model,
      # so normally they should be identical.  We encourage model editing though, so they may
      # not be identical under some edits.  Also, if the model is a DP model then the weights are
      # probably different due to the noise contribution.  Let's take the geometic mean to compensate.
      total_weight = exp(
          sum(log(axis_sum) for axis_sum in axis_sums) / len(axis_sums)
      )
      axis_percentages = [
          weights / axis_sum
          for weights, axis_sum in zip(axis_weights, axis_sums)
      ]
  
      shape = tuple(map(len, axis_percentages))
      n_cells = np.prod(shape)
      tensor = np.empty(n_cells, np.float64)
  
      # the last index items are next together in flat memory layout
      axis_percentages.reverse()
  
      for cell_idx in range(n_cells):
          remainder = cell_idx
          frac = 1.0
          for percentages in axis_percentages:
              bin_idx = remainder % len(percentages)
              remainder //= len(percentages)
              frac *= percentages[bin_idx]
          val = frac * total_weight
          tensor.itemset(cell_idx, val)
      return tensor.reshape(shape)
  
imports: from math import ceil, isnan, isinf, exp, log
  from ...utils._native import Native
  from ._tensor import restore_missing_value_zeros
  import numpy
  import warnings
  from itertools import islice
  import logging
label_desc: Use image node_id 3 for calling a global function with example usage: _create_proportional_tensor(axis_weights) and returns: tensor