code: def _bucket_stats(bucket_sample_ids, seq_lengths):
      bucket_average_lengths = []
      bucket_length_stds = []
      for sample_ids in bucket_sample_ids:
          if len(sample_ids) > 0:
              lengths = seq_lengths[sample_ids]
              bucket_average_lengths.append(np.mean(lengths))
              bucket_length_stds.append(np.std(lengths))
          else:
              bucket_average_lengths.append(0)
              bucket_length_stds.append(0)
      return bucket_average_lengths, bucket_length_stds
  
imports: import math
  import random
  import warnings
  import numpy
  import abc
  import logging
  from typing import Union, Sequence, Optional, List
  from ..base import INT_TYPES
label_desc: Use image node_id 2 for calling a global function with example usage: _bucket_stats(bucket_sample_ids, seq_lengths) and returns: bucket_average_lengths,  bucket_length_stds