code: def _get_native_variables_and_indices(
      x, reshape=True, idxs=None, create_var=False
  ):
      """Extract all relevant results from the output nested structure of a
      function."""
  
      def map_fn(x_):
          if ivy.is_array(x_):
              x_ = ivy.to_ivy(x_) if ivy.is_native_array(x_) else x_
              if create_var:
                  x_ = (
                      x_
                      if _is_variable(x_, exclusive=True)
                      else _variable(x_)
                  )
              if len(x_.shape) == 0:
                  return ivy.to_native(x_)
              if reshape:
                  if x_.size == 1:
                      if reshape:
                          return ivy.to_native(ivy.reshape(x_, []))
                      return ivy.to_native(x_)
                  else:
                      return ivy.to_ivy(x_)
              else:
                  return ivy.to_native(x_)
          return x_
  
      if ivy.is_array(x):
          return [], map_fn(x)
  
      x = ivy.nested_map(map_fn, x, include_derived=True, shallow=False)
      arr_idxs = ivy.nested_argwhere(
          x, lambda x: ivy.is_native_array(x)
      )
      if _check_if_empty(arr_idxs):
          return arr_idxs, []
      else:
          if idxs is not None:
              arr_idxs = [
                  arr_idx
                  for arr_idx in arr_idxs
                  if "_".join(str(x) for x in arr_idx)
                  in _idxs_to_str(idxs)
              ]
          arr_values = ivy.multi_index_nest(x, arr_idxs)
          arr_idxs = _idxs_to_str(arr_idxs)
          return arr_idxs, arr_values
  
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 5 for calling a global function with example usage: _get_native_variables_and_indices(x, reshape, idxs, create_var) and returns: x_, list,  map_fn, arr_idxs,  list, arr_idxs,  arr_values, ivy, ivy, ivy, ivy, ivy