code: def byteCost(widths, default, nominal):
      if not hasattr(widths, "items"):
          d = defaultdict(int)
          for w in widths:
              d[w] += 1
          widths = d
  
      cost = 0
      for w, freq in widths.items():
          if w == default:
              continue
          diff = abs(w - nominal)
          if diff <= 107:
              cost += freq
          elif diff <= 1131:
              cost += freq * 2
          else:
              cost += freq * 5
      return cost
  
file_path: catboost/contrib/python/fonttools/fontTools/cffLib/width.py
imports: from fontTools.ttLib import TTFont
  from collections import defaultdict
  from operator import add
  from functools import reduce
label_desc: Use image node_id 2 for calling a global function with example usage: byteCost(widths, default, nominal) and returns: cost