code: def bucket_distance(offsets):
      """offsets: [num spans1, num spans2]"""
      # 10 semi-logscale bin: 0, 1, 2, 3, 4, (5-7)->5, (8-15)->6, (16-31)->7, (32-63)->8, (64+)->9
      logspace_distance = (
          torch.log2(offsets.to(torch.float)).to(torch.long) + 3
      )
      identity_mask = (offsets <= 4).to(torch.long)
      combined_distance = (
          identity_mask * offsets
          + (1 - identity_mask) * logspace_distance
      )
      combined_distance = torch.clamp(combined_distance, 0, 9)
      return combined_distance
  
imports: import sys
  import os
  from os import makedirs
  from os.path import join
  import numpy
  import pyhocon
  import math
  import logging
  import random
  from typing import Optional, Tuple, Any, Dict, Iterable, Union
  import torch
  import torch.nn.functional
  from torch import nn
  from transformers.activations import ACT2FN
label_desc: Use image node_id 4 for calling a global function with example usage: bucket_distance(offsets) and returns: combined_distance