code: def argsort(
      keys: List[Any], *lists: List[List[Any]], descending: bool = False
  ):
      """
      Reorder each list in lists by the (descending) sorted order of keys.
  
      :param iter keys:
          Keys to order by.
      :param list[list] lists:
          Lists to reordered by keys's order.  Correctly handles lists and 1-D
          tensors.
      :param bool descending:
          Use descending order if true.
  
      :returns:
          The reordered items.
      """
      ind_sorted = sorted(range(len(keys)), key=lambda k: keys[k])
      if descending:
          ind_sorted = list(reversed(ind_sorted))
      output = []
      for lst in lists:
          # watch out in case we don't have torch installed
          if isinstance(lst, torch.Tensor):
              output.append(lst[ind_sorted])
          else:
              output.append([lst[i] for i in ind_sorted])
      return output
  
imports: import os
  from typing import Union, Optional, Tuple, Any, List, Sized, TypeVar
  import itertools
  from collections import namedtuple
  import parlai.utils.logging
  import parlai.utils.io
  import torch.optim
label_desc: Use image node_id 6 for calling a global function with example usage: argsort(keys) and returns: output