code: def get_bucket_number(
      hkey,
      num_buckets: int,
      max_hkey: Optional[int] = None,
  ) -> int:
      """Returns bucket (shard) number (int) for given hashed key (int)."""
      # We purposely do not use modulo (%) to keep global order across shards.
      # floor(key * num_buckets / HKEYS_NUMBER), with HKEYS_NUMBER = 2**HKEY_SIZE.
      max_hkey = max_hkey or 2**HKEY_SIZE
      # Make sure that we do not return `bucket_number`.
      return min(
          math.trunc((hkey * num_buckets) / max_hkey), num_buckets - 1
      )
  
imports: import math
  import os
  import struct
  from typing import Iterator, List, Optional
  import uuid
  from absl import logging
  import six
  from tensorflow_datasets.core import hashing
  from tensorflow_datasets.core.utils import file_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: get_bucket_number(hkey, num_buckets, max_hkey) and returns: min