code: def split_to_even_chunks(indices, lengths, num_chunks):
      """
      Split a list of indices into `chunks` chunks of roughly equal lengths.
      """
  
      if len(indices) % num_chunks != 0:
          return [indices[i::num_chunks] for i in range(num_chunks)]
  
      num_indices_per_chunk = len(indices) // num_chunks
  
      chunks = [[] for _ in range(num_chunks)]
      chunks_lengths = [0 for _ in range(num_chunks)]
      for index in indices:
          shortest_chunk = chunks_lengths.index(min(chunks_lengths))
          chunks[shortest_chunk].append(index)
          chunks_lengths[shortest_chunk] += lengths[index]
          if len(chunks[shortest_chunk]) == num_indices_per_chunk:
              chunks_lengths[shortest_chunk] = float("inf")
  
      return chunks
  
imports: import os
  import torch
  import torch.nn
  from fairscale.optim import OSS
  from torch.utils.data import Sampler
  from transformers import Trainer
  from transformers.pytorch_utils import ALL_LAYERNORM_LAYERS
  from transformers.trainer_pt_utils import get_parameter_names
  from transformers.trainer_utils import ShardedDDPOption, has_length
  from transformers.utils import is_sagemaker_mp_enabled, logging
  from typing import List, Optional, Union, Dict, Any
label_desc: Use image node_id 3 for calling a global function with example usage: split_to_even_chunks(indices, lengths, num_chunks) and returns: chunks, unknown