code: def _extract_intervals(offsets, sizes, data):
      """Select contiguous intervals of rows, given their offsets and sizes.
      E.g. suppose offsets = [35, 70, 90], sizes = [3, 2, 4], then this will
      return
  
              (torch.LongTensor(0, 3, 5),
              data[torch.LongTensor([35, 36, 37, 70, 71, 90, 91, 92, 93])])
  
      """
      offsets = offsets.long()
      sizes = sizes.long()
      res_rows = sizes.sum().item()
      assert offsets.size(0) == sizes.size(0)
  
      non_zero_size = sizes != 0
      if non_zero_size.long().sum() == 0:
          return torch.zeros(offsets.size(0) + 1).long(), data.new()
  
      new_offsets = torch.cat([torch.LongTensor([0]), sizes.cumsum(0)])
      sizes_nz = sizes[non_zero_size]
      offsets_nz = offsets[non_zero_size]
  
      res_delta = torch.LongTensor(res_rows).fill_(1)
      res_delta[0] = offsets_nz[0]
  
      if offsets_nz.size(0) > 1:
          input_delta = (
              offsets_nz[1:] - offsets_nz[:-1] - sizes_nz[:-1]
          )  # [32, 18]
          res_row_offsets = sizes_nz.cumsum(0)[:-1]  # [3, 5]
          res_delta[
              res_row_offsets
          ] += input_delta  # [35, 1, 1, 33, 1, 19, 1, 1, 1]
  
      res_offsets = res_delta.cumsum(
          0
      )  # [35, 36, 37, 70, 71, 90, 91, 92, 93]
      res = data[res_offsets]
  
      return new_offsets, res
  
imports: import torch
label_desc: Use image node_id 1 for calling a global function with example usage: _extract_intervals(offsets, sizes, data) and returns: new_offsets,  res, torch,  data