class_docstr: Coref Sample
class_docstr_tok: ["Coref","Sample"]
docstr: Given a CorefSample and shuffled sentence indexes, reproduce
  a CorefSample with respect to the indexes.
  
  :param list sen_idxs: a list of ints. the indexes in a shuffled order
          we expect `sen_idxs` is like [1, 3, 0, 4, 2, 5] when sen_num = 6
  :return ~textflint.input.component.sample.CorefSample:
      a CorefSample with respect to the shuffled index
docstr_tok: ["Given","a","CorefSample","and","shuffled","sentence","indexes",",","reproduce","a","CorefSample","with","respect","to","the","indexes",".",":","param","list","sen_idxs",":","a","list","of","ints",".","the","indexes","in","a","shuffled","order","we","expect","`","sen_idxs","`","is","like","[","1",",","3",",","0",",","4",",","2",",","5","]","when","sen_num","=","6",":","return","~textflint.input.component.sample.CorefSample",":","a","CorefSample","with","respect","to","the","shuffled","index"]
code: def shuffle_conll(self, sen_idxs):
      r"""
      Given a CorefSample and shuffled sentence indexes, reproduce
      a CorefSample with respect to the indexes.
  
      :param list sen_idxs: a list of ints. the indexes in a shuffled order
              we expect `sen_idxs` is like [1, 3, 0, 4, 2, 5] when sen_num = 6
      :return ~textflint.input.component.sample.CorefSample:
          a CorefSample with respect to the shuffled index
  
      """
      # arg check
      assert len(sen_idxs) == self.num_sentences()
      assert len(set(sen_idxs)) == self.num_sentences()
      assert (
          sum(sen_idxs)
          == self.num_sentences() * (self.num_sentences() - 1) / 2
      )
      # logic
      doc_key = self.doc_key
      # speakers, sentences
      sentences = CorefSample.doc2sens(self.x.words, self.sen_map)
      sens = [sentences[i] for i in sen_idxs]
      speakers = CorefSample.doc2sens(self.doc_sp.words, self.sen_map)
      sps = [speakers[i] for i in sen_idxs]
      # clusters, constituents, ner
  
      @shift_decor
      def index_shift(word_idx):
          # word_idx is in the sen_idx-th sentence
          sen_idx = self.index_in_sen(word_idx)
          ori_shift = sum(self.sen_map[:sen_idx])
          # shf_shift
          shf_sen_idx = sen_idxs.index(sen_idx)
          shf_shift = 0
          for j in range(shf_sen_idx):
              shf_shift += self.sen_map[sen_idxs[j]]
          return word_idx - (ori_shift - shf_shift)
  
      clusters = recur_ap(index_shift, self.clusters.field_value)
      constituents = recur_ap(
          index_shift, self.constituents.field_value
      )
      ner = recur_ap(index_shift, self.ner.field_value)
      ret_conll = {
          "doc_key": doc_key,
          "sentences": sens,
          "speakers": sps,
          "clusters": clusters,
          "constituents": constituents,
          "ner": ner,
      }
      return CorefSample(data=ret_conll, origin=self)
  
imports: from ....common.settings import ORIGIN, TASK_MASK
  from ....common.utils.fp_utils import *
  from ....common.utils.shift_utils import *
  from .sample import Sample
  from ..field import ListField, TextField
label_desc: Use image node_id 19 for calling the CorefSample obj's underlying member method code with example usage: obj.shuffle_conll(sen_idxs) and returns: CorefSample, unknown