class_docstr: Replace entity mention with entity with same entity types
docstr: transform both subject and object entities
  
  :param RESample sample: re_sample input
  :param int n: number of generated samples
  :return list: transformed sample list
docstr_tok: ["transform","both","subject","and","object","entities",":","param","RESample","sample",":","re_sample","input",":","param","int","n",":","number","of","generated","samples",":","return","list",":","transformed","sample","list"]
code: def subj_and_obj_transform(self, sample, n, entity):
      r"""
      transform both subject and object entities
  
      :param RESample sample: re_sample input
      :param int n: number of generated samples
      :return list: transformed sample list
  
      """
      assert isinstance(
          n, int
      ), f"the type of 'n' should be int, got {type(n)} instead"
      assert isinstance(
          entity, list
      ), f"the type of 'entity' should be list, got {type(entity)} instead"
      assert isinstance(sample, RESample), (
          f"the type of 'sample' should be RESample, got "
          f"{type(sample)} instead"
      )
      assert len(entity) == 6, (
          f"the length of entity should be 6, got input length of "
          f"{len(entity)} instead"
      )
      assert (
          entity[0] <= entity[1] and entity[2] <= entity[3]
      ), f"start index of entity should not be greater than end index, got  \
                      {entity[0]}>{entity[1]} or {entity[2]}>{entity[3]} instead"
      assert isinstance(entity[4], str) and isinstance(
          entity[5], str
      ), (
          f"last two elements of entity should be string, "
          f"got type {entity[4]} and {entity[5]} instead"
      )
      assert (
          entity[4] in self.type_dict.keys()
          and entity[5] in self.type_dict.keys()
      ), (
          f"both entity types should be in the type dict, type "
          f"{entity[4]} and {entity[5]} do not satisfy this requirement"
      )
  
      trans_samples = []
  
      for i in range(n):
          sh, st, oh, ot, subj_type, obj_type = entity
          token, relation = sample.get_sent()
          trans_sample = {}
  
          if sh < oh:
              token, l1 = self.replace_en(subj_type, [sh, st], token)
              st, oh, ot = st + l1, oh + l1, ot + l1
              token, l2 = self.replace_en(obj_type, [oh, ot], token)
              ot = ot + l2
          elif oh < sh:
              token, l1 = self.replace_en(obj_type, [oh, ot], token)
              ot, sh, st = ot + l1, sh + l1, st + l1
              token, l2 = self.replace_en(subj_type, [sh, st], token)
              st = st + l2
          else:
              token, l = self.replace_en(subj_type, [sh, st], token)
              st, ot = st + l, ot + l
          trans_sample["x"] = token
          (
              trans_sample["subj"],
              trans_sample["obj"],
              trans_sample["y"],
          ) = ([sh, st], [oh, ot], relation)
          new_samples = sample.replace_sample_fields(trans_sample)
          trans_samples.append(new_samples)
      return trans_samples
  
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 4 for calling the SwapEnt obj's underlying member method code with example usage: obj.subj_and_obj_transform(sample, n, entity) and returns: trans_samples