nodes: 0, module; 1, function_definition; 2, function_name:get_toplosses_idxs; 3, parameters; 4, block; 5, identifier:cls; 6, identifier:learn; 7, identifier:n_imgs; 8, dictionary_splat_pattern; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, return_statement; 15, identifier:kwargs; 16, string:"Sorts `ds_type` dataset by top losses and returns dataset and sorted indices."; 17, assignment; 18, not_operator; 19, block; 20, assignment; 21, assignment; 22, expression_list; 23, identifier:dl; 24, attribute; 25, identifier:n_imgs; 26, expression_statement; 27, pattern_list; 28, call; 29, identifier:idxs; 30, subscript; 31, call; 32, identifier:idxs; 33, attribute; 34, identifier:fix_dl; 35, assignment; 36, identifier:_; 37, identifier:_; 38, identifier:top_losses; 39, attribute; 40, argument_list; 41, call; 42, integer:1; 43, attribute; 44, argument_list; 45, identifier:learn; 46, identifier:data; 47, identifier:n_imgs; 48, call; 49, identifier:learn; 50, identifier:get_preds; 51, keyword_argument; 52, keyword_argument; 53, attribute; 54, argument_list; 55, identifier:cls; 56, identifier:padded_ds; 57, attribute; 58, dictionary_splat; 59, identifier:len; 60, argument_list; 61, identifier:ds_type; 62, attribute; 63, identifier:with_loss; 64, True; 65, identifier:torch; 66, identifier:topk; 67, identifier:top_losses; 68, identifier:n_imgs; 69, identifier:dl; 70, identifier:dataset; 71, identifier:kwargs; 72, attribute; 73, identifier:DatasetType; 74, identifier:Fix; 75, identifier:dl; 76, identifier:dataset
code: def get_toplosses_idxs(cls, learn, n_imgs, **kwargs):
          "Sorts `ds_type` dataset by top losses and returns dataset and sorted indices."
          dl = learn.data.fix_dl
          if not n_imgs: n_imgs = len(dl.dataset)
          _,_,top_losses = learn.get_preds(ds_type=DatasetType.Fix, with_loss=True)
          idxs = torch.topk(top_losses, n_imgs)[1]
          return cls.padded_ds(dl.dataset, **kwargs), idxs