class_docstr: Replace entity mention with entity with same entity types
docstr: Transform text string according to its entities.
  
  :param RESample sample: re_sample input
  :param int n: number of generated samples
  :return list: transformed sample list
docstr_tok: ["Transform","text","string","according","to","its","entities",".",":","param","RESample","sample",":","re_sample","input",":","param","int","n",":","number","of","generated","samples",":","return","list",":","transformed","sample","list"]
code: def _transform(self, sample, n=1, **kwargs):
      r"""
      Transform text string according to its entities.
  
      :param RESample sample: re_sample input
      :param int n: number of generated samples
      :return list: transformed sample list
  
      """
      assert isinstance(sample, RESample), (
          f"the type of 'sample' should be RESample, "
          f"got {type(sample)} instead"
      )
      assert isinstance(
          n, int
      ), f"the type of 'n' should be int, got {type(n)} instead"
      sh, st, oh, ot = sample.get_en()
      subj_type, obj_type, _ = sample.get_type()
      if (
          subj_type in self.type_dict.keys()
          and obj_type in self.type_dict.keys()
      ):
          return self.subj_and_obj_transform(
              sample, n, [sh, st, oh, ot, subj_type, obj_type]
          )
      elif (
          subj_type not in self.type_dict.keys()
          or obj_type not in self.type_dict.keys()
      ):
          return self.single_transform(
              sample, n, [sh, st, oh, ot, subj_type, obj_type]
          )
      return [sample] * n
  
file_path: textflint/textflint/generation/transformation/RE/swap_ent.py
imports: import random
  from ....common.settings import LOWFREQ, MULTI_TYPE, TYPES
  from ....common.utils.install import download_if_needed
  from ....common.utils.load import json_loader
  from ...transformation import Transformation
  from ....input.component.sample import RESample
label_desc: Use image node_id 6 for calling the SwapEnt obj's underlying member method code with example usage: obj._transform(sample, n) and returns: unknown, self, self