code: def _rebuild_flattened_containers(outputs, ret_idxs):
      """Rebuild the containers from the flattened arrays into a single tuple."""
      rebuilt_outputs = []
      curr_idx = 0
      for ret_idx in ret_idxs:
          if ret_idx is None:
              rebuilt_outputs.append(outputs[curr_idx])
              curr_idx += 1
          else:
              cont = ivy.Container()
              num_elements = len(ret_idx)
              cont_outputs = outputs[curr_idx : curr_idx + num_elements]
              ivy.insert_into_nest_at_indices(
                  cont, ret_idx, cont_outputs
              )
              rebuilt_outputs.append(cont)
              curr_idx += num_elements
      return tuple(rebuilt_outputs)
  
imports: from typing import Sequence, Union, Optional, Tuple, Callable
  import numpy
  import itertools
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, inputs_to_ivy_arrays, to_native_arrays_and_back, 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 16 for calling a global function with example usage: _rebuild_flattened_containers(outputs, ret_idxs) and returns: tuple