code: def _lens_to_boundaries(
      lengths, slice_start=None, slice_end=None, cumulative=True
  ):
      """Converts a tensor of lengths to a tensor of start and end
      boundaries, used for concat_padded_features
  
  
      Arguments
      ---------
      lengths: torch.Tensor
          a (component x batch) tensor of absolute lengths
  
      slice_start: torch.Tensor
          a (component x batch) tensor of relative start offsets
  
      slice_end: torch.Tensor
          a (component x batch) tensor of relative end offsets
  
      cumultative: True
          if true, the start of a given component is assumed to
          be at the end of the previous component.
          if false, all components start at the beginning of the
          length dimension
      """
      batch_size = lengths.size(-1)
      batch_padding = (
          torch.zeros((1, batch_size)).int().to(lengths.device)
      )
  
      if slice_start is None:
          start_offset = torch.tensor(0).to(lengths.device)
      else:
          start_offset = (lengths * slice_start).floor().int()
  
      if slice_end is None:
          end_offset = torch.tensor(0).to(lengths.device)
      else:
          end_offset = (lengths * slice_end).floor().int()
  
      if cumulative:
          effective_lengths = lengths - start_offset - end_offset
          effective_lengths_zpad = torch.concat(
              [batch_padding, effective_lengths], dim=0
          )
  
          start = effective_lengths_zpad.cumsum(dim=0)[:-1, :]
      else:
          start = torch.zeros(*lengths.shape).to(lengths.device)
      start += start_offset
      end = start + lengths - end_offset
      return start, end
  
imports: import math
  import os
  import re
  import csv
  import shutil
  import urllib.request
  import collections.abc
  import torch
  import tqdm
  import pathlib
  import speechbrain
  from numbers import Number
label_desc: Use image node_id 24 for calling a global function with example usage: _lens_to_boundaries(lengths, slice_start, slice_end, cumulative) and returns: start,  end