class_docstr: Transforms an input by Reverse gender or place names in sentences.
class_docstr_tok: ["Transforms","an","input","by","Reverse","gender","or","place","names","in","sentences","."]
docstr: Transform text string according transform_field.
  
  :param ~Sample sample: input data, normally one data component.
  :param str field:  indicate which field to transform.
  :param int n: number of generated samples
  :param kwargs:
  :return list trans_samples: transformed sample list.
docstr_tok: ["Transform","text","string","according","transform_field",".",":","param","~Sample","sample",":","input","data",",","normally","one","data","component",".",":","param","str","field",":","indicate","which","field","to","transform",".",":","param","int","n",":","number","of","generated","samples",":","param","kwargs",":",":","return","list","trans_samples",":","transformed","sample","list","."]
code: def _transform(self, sample, field="x", n=5, **kwargs):
      r"""
      Transform text string according transform_field.
  
      :param ~Sample sample: input data, normally one data component.
      :param str field:  indicate which field to transform.
      :param int n: number of generated samples
      :param kwargs:
      :return list trans_samples: transformed sample list.
  
      """
      # get the word in sentence
      words = sample.get_words(field)
      words_indices = []
      idx = 0
      for word in words:
          words_indices.append((idx, idx + len(word)))
          idx += len(word)
  
      trans_samples = []
      if self.flag_type:
          change_pos, change_item = self._get_name_change(
              words, words_indices, n
          )
      else:
          change_pos, change_item = self._get_loc_change(
              words, words_indices, n
          )
      if change_pos:
          change_item = descartes(change_item, n)
  
      n = min(n, len(change_item))
  
      for i in range(n):
          # get the change position and change items
          trans_sample = sample.unequal_replace_field_at_indices(
              field, change_pos, change_item[i]
          )
          trans_samples.append(trans_sample)
  
      return trans_samples
  
file_path: textflint/textflint/generation/transformation/UTCN/cn_prejudice.py
imports: import random
  from ..transformation import Transformation
  from ....common.utils.list_op import descartes
  from ....common.utils.load import json_loader
  from ....common.utils.install import download_if_needed
  from ....common.settings import PREJUDICE_LOC2IDX, CN_NAME_PATH, CN_PREJUDICE_WORD_PATH, CN_LOC2IDX_PATH
label_desc: Use image node_id 3 for calling the CnPrejudice obj's underlying member method code with example usage: obj._transform(sample, field, n) and returns: trans_samples