code: def average_buckets(
      tensor: torch.Tensor, quant_weight: torch.Tensor, n_bins: int
  ):
      """Return the average value in each bucket"""
      bin_sums = torch.zeros(n_bins).scatter_add_(
          0, quant_weight.flatten().long(), tensor.flatten()
      )
      bin_counts = torch.clamp_min_(
          torch.bincount(quant_weight.flatten(), minlength=n_bins), 1
      )
      lookup = bin_sums / bin_counts
      return lookup
  
imports: import math
  import os
  import warnings
  from abc import ABC, abstractmethod
  from concurrent.futures import ThreadPoolExecutor
  from typing import Tuple
  import numpy
  import torch
  from hivemind.compression.base import CompressionBase, CompressionInfo
  from hivemind.proto import runtime_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: average_buckets(tensor, quant_weight, n_bins) and returns: lookup