code: def order_result(
      unordered_result: Generator[Tuple[int, Any], None, None]
  ) -> List:
      """
      Re-orders the result of a distributed explainer so that the explanations follow the same order as the input to
      the explainer.
  
      Parameters
      ----------
      unordered_result
          Each tuple contains the batch id as the first entry and the explanations for that batch as the second.
  
      Returns
      -------
      A list with re-ordered results.
  
      Notes
      -----
      This should not be used if one wants to take advantage of the results being returned as they are calculated.
      """
  
      result_order, results = list(
          zip(*[(idx, res) for idx, res in unordered_result])
      )
      orig_order = invert_permutation(list(result_order))
      ordered_result = [results[idx] for idx in orig_order]
  
      return ordered_result
  
imports: import copy
  import logging
  from functools import partial
  from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
  import numpy
  from scipy import sparse
  import ray
label_desc: Use image node_id 6 for calling a global function with example usage: order_result(unordered_result) and returns: ordered_result