class_docstr: Coref Sample
class_docstr_tok: ["Coref","Sample"]
docstr: Only sentences with `indexs` will be kept, and all the structures of
  `clusters` are kept for convenience of concat.
  
  :param list pres_idxs: a list of ints. the indexes to be preserved
      we expect `pres_idxs` is from [0..num_sen], and is in ascending
      order, like [0, 1, 3, 5] when num_sen = 6
  :return ~textflint.input.component.sample.CorefSample:
      a CorefPartSample of a conll-part
docstr_tok: ["Only","sentences","with","`","indexs","`","will","be","kept",",","and","all","the","structures","of","`","clusters","`","are","kept","for","convenience","of","concat",".",":","param","list","pres_idxs",":","a","list","of","ints",".","the","indexes","to","be","preserved","we","expect","`","pres_idxs","`","is","from","[","0","..","num_sen","]",",","and","is","in","ascending","order",",","like","[","0",",","1",",","3",",","5","]","when","num_sen","=","6",":","return","~textflint.input.component.sample.CorefSample",":","a","CorefPartSample","of","a","conll-part"]
code: def part_conll(self, pres_idxs):
      r"""
      Only sentences with `indexs` will be kept, and all the structures of
      `clusters` are kept for convenience of concat.
  
      :param list pres_idxs: a list of ints. the indexes to be preserved
          we expect `pres_idxs` is from [0..num_sen], and is in ascending
          order, like [0, 1, 3, 5] when num_sen = 6
      :return ~textflint.input.component.sample.CorefSample:
          a CorefPartSample of a conll-part
      """
      # arg check
      sorted_idxs = sorted(pres_idxs)
      if len(sorted_idxs) >= 1:
          assert sorted_idxs[0] >= 0
          assert sorted_idxs[-1] < self.num_sentences()
      if len(sorted_idxs) >= 2:
          for i in range(len(sorted_idxs) - 1):
              assert sorted_idxs[i] < sorted_idxs[i + 1]
      # main logic
      doc_key = self.doc_key
      # sentences, speakers
      sentences = CorefSample.doc2sens(self.x.words, self.sen_map)
      sens = [sentences[i] for i in pres_idxs]
      speakers = CorefSample.doc2sens(self.doc_sp.words, self.sen_map)
      sps = [speakers[i] for i in pres_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])
          del_shift = sum(
              [self.sen_map[i] for i in pres_idxs if i < sen_idx]
          )
          return word_idx - (ori_shift - del_shift)
  
      def preserve(span):
          return self.index_in_sen(span[0]) in pres_idxs
  
      clusters = recur_ap(
          index_shift,
          [
              [span for span in cluster if preserve(span)]
              for cluster in self.clusters.field_value
          ],
      )
      constituents = recur_ap(
          index_shift,
          [
              span
              for span in self.constituents.field_value
              if preserve(span)
          ],
      )
      ner = recur_ap(
          index_shift,
          [span for span in self.ner.field_value if preserve(span)],
      )
      ret_conll = {
          "doc_key": doc_key,
          "sentences": sens,
          "speakers": sps,
          "clusters": clusters,
          "constituents": constituents,
          "ner": ner,
      }
      return CorefPartSample(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 20 for calling the CorefSample obj's underlying member method code with example usage: obj.part_conll(pres_idxs) and returns: CorefPartSample, unknown, unknown