class_docstr: Parallelly transforms input by common abbreviations in TwitterType.
  
  :param str mode: Twitter type, only support ['at', 'url', 'random']
class_docstr_tok: ["Parallelly","transforms","input","by","common","abbreviations","in","TwitterType",".",":","param","str","mode",":","Twitter","type",",","only","support","[","'at","'",",","'url","'",",","'random","'","]"]
docstr: Transform text string according transform_field.
  
  :param ~Sample sample: input data, normally one data component.
  :param str|list 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|list","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=["source", "target"], n=1, **kwargs
  ):
      r"""
      Transform text string according transform_field.
  
      :param ~Sample sample: input data, normally one data component.
      :param str|list field: indicate which field to transform.
      :param int n: number of generated samples
      :param kwargs:
      :return list trans_samples: transformed sample list.
  
      """
      trans_samples = []
      contract_sample = sample
  
      random_texts = self._get_random_text(n=n)
  
      for random_text in random_texts:
          insert_beginning = random.choice([True, False])
          # insert at the beginning
          if insert_beginning:
              trans_sample = contract_sample.insert_field_before_index(
                  field[0], 0, random_text
              ).insert_field_before_index(field[1], 0, random_text)
          else:
              source_end_index = (
                  len(contract_sample.get_words(field[0])) - 1
              )
              target_end_index = (
                  len(contract_sample.get_words(field[1])) - 1
              )
              trans_sample = contract_sample.insert_field_after_index(
                  field[0], source_end_index, random_text
              ).insert_field_after_index(
                  field[1], target_end_index, random_text
              )
          trans_samples.append(trans_sample)
  
      return trans_samples
  
file_path: textflint/textflint/generation/transformation/NMT/parallel_twitter_type.py
imports: import random
  import string
  import numpy
  from ....common.utils.error import FlintError
  from ....common.utils import logger
  from ..UT.twitter_type import TwitterType
label_desc: Use image node_id 3 for calling the ParallelTwitterType obj's underlying member method code with example usage: obj._transform(sample, field, n) and returns: trans_samples