code: def calc_bucketing_batch_sizes(ds_config, datasets_len):
      bucketing_batch_size = ds_config["bucketing_batch_size"]
      bucketing_weights = ds_config.get(
          "bucketing_weights", None
      )  # To adjust for upsampled buckets
  
      bucketing_batch_sizes = []
  
      if ds_config["batch_size"] != 1:
          raise ValueError(
              f"batch_size should be set to one when bucketing_batch_size is set and adaptive bucketing is enabled (batch_size={ds_config['batch_size']}!"
          )
      if type(bucketing_batch_size) == int:  # linear scaling
          if (
              bucketing_weights
          ):  # Want same batchsize for the same duplicated bucket
              for idx, weight in enumerate(bucketing_weights):
                  scale_factor = datasets_len - idx
                  [
                      bucketing_batch_sizes.append(
                          scale_factor * bucketing_batch_size
                      )
                      for _ in range(weight)
                  ]
          else:
              for idx in range(datasets_len):
                  scale_factor = datasets_len - idx
                  bucketing_batch_sizes.append(
                      scale_factor * bucketing_batch_size
                  )
      elif isinstance(bucketing_batch_size, ListConfig) or isinstance(
          bucketing_batch_size, list
      ):  # assigned bucket sizes
          if (
              bucketing_weights
          ):  # Want same batchsize for same duplicated bucket
              for idx, weight in enumerate(bucketing_weights):
                  [
                      bucketing_batch_sizes.append(
                          bucketing_batch_size[idx]
                      )
                      for _ in range(weight)
                  ]
          else:
              bucketing_batch_sizes = bucketing_batch_size
      else:
          raise ValueError(
              f"bucketing_batch_size should be an integer or a list (bucketing_batch_size={bucketing_batch_size})!"
          )
  
      if len(bucketing_batch_sizes) != datasets_len:
          raise ValueError(
              f"batch_size should have the same length as the number of buckets ({len(bucketing_batch_sizes)}!={datasets_len}) "
          )
      return bucketing_batch_sizes
  
imports: import copy
  import json
  import random
  from math import isclose
  from typing import Any, List, Optional, Union
  import torch
  from omegaconf import DictConfig, OmegaConf, open_dict
  from omegaconf.listconfig import ListConfig
  from pytorch_lightning.callbacks import BasePredictionWriter
  from torch.utils.data import ChainDataset
  from nemo.collections.asr.data import audio_to_text, audio_to_text_dali
  from nemo.collections.asr.data.huggingface.hf_audio_to_text_dataset import get_hf_audio_to_text_bpe_dataset, get_hf_audio_to_text_char_dataset
  from nemo.collections.asr.parts.preprocessing.perturb import process_augmentations
  from nemo.collections.common.data.dataset import CodeSwitchedDataset, ConcatDataset
  from nemo.utils import logging
label_desc: Use image node_id 15 for calling a global function with example usage: calc_bucketing_batch_sizes(ds_config, datasets_len) and returns: bucketing_batch_sizes