code: def _pack_padded_sequence(input, lengths):
      input = ivy.swapaxes(input, 0, 1)
      data = []
      batch_sizes = []
      for i in range(int(max(lengths))):
          valid_data_mask = ivy.array(lengths) > i
          data.append(input[valid_data_mask, i])
          batch_sizes.append(int(sum(valid_data_mask)))
      data = ivy.concat(data)
      batch_sizes = ivy.array(batch_sizes, dtype=ivy.int64)
      return data, batch_sizes
  
imports: from typing import Optional, Tuple, Union, Sequence
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, handle_partial_mixed_function, inputs_to_ivy_arrays, to_native_arrays_and_back, inputs_to_native_shapes, handle_out_argument, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 29 for calling a global function with example usage: _pack_padded_sequence(input, lengths) and returns: data,  batch_sizes