def __init__(self, mobject: 'Mobject', target_mobject: 'Mobject', transform_mismatches: bool=False, fade_transform_mismatches: bool=False, key_map: Optional[dict]=None, **kwargs):
    assert (type(mobject) is type(target_mobject))
    if isinstance(mobject, OpenGLVMobject):
        group_type = OpenGLVGroup
    elif isinstance(mobject, OpenGLMobject):
        group_type = OpenGLGroup
    elif isinstance(mobject, VMobject):
        group_type = VGroup
    else:
        group_type = Group
    source_map = self.get_shape_map(mobject)
    target_map = self.get_shape_map(target_mobject)
    if (key_map is None):
        key_map = {}
    transform_source = group_type()
    transform_target = group_type()
    kwargs['final_alpha_value'] = 0
    for key in set(source_map).intersection(target_map):
        transform_source.add(source_map[key])
        transform_target.add(target_map[key])
    anims = [Transform(transform_source, transform_target, **kwargs)]
    key_mapped_source = group_type()
    key_mapped_target = group_type()
    for (key1, key2) in key_map.items():
        if ((key1 in source_map) and (key2 in target_map)):
            key_mapped_source.add(source_map[key1])
            key_mapped_target.add(target_map[key2])
            source_map.pop(key1, None)
            target_map.pop(key2, None)
    if (len(key_mapped_source) > 0):
        anims.append(FadeTransformPieces(key_mapped_source, key_mapped_target, **kwargs))
    fade_source = group_type()
    fade_target = group_type()
    for key in set(source_map).difference(target_map):
        fade_source.add(source_map[key])
    for key in set(target_map).difference(source_map):
        fade_target.add(target_map[key])
    if transform_mismatches:
        if ('replace_mobject_with_target_in_scene' not in kwargs):
            kwargs['replace_mobject_with_target_in_scene'] = True
        anims.append(Transform(fade_source, fade_target, **kwargs))
    elif fade_transform_mismatches:
        anims.append(FadeTransformPieces(fade_source, fade_target, **kwargs))
    else:
        anims.append(FadeOut(fade_source, target_position=fade_target, **kwargs))
        anims.append(FadeIn(fade_target.copy(), target_position=fade_target, **kwargs))
    super().__init__(*anims)
    self.to_remove = mobject
    self.to_add = target_mobject
def __init__(self, mobject: 'Mobject', target_mobject: 'Mobject', transform_mismatches: bool=False, fade_transform_mismatches: bool=False, key_map: Optional[dict]=None, **kwargs):
    assert (type(mobject) is type(target_mobject))
    if isinstance(mobject, OpenGLVMobject):
        group_type = OpenGLVGroup
    elif isinstance(mobject, OpenGLMobject):
        group_type = OpenGLGroup
    elif isinstance(mobject, VMobject):
        group_type = VGroup
    else:
        group_type = Group
    source_map = self.get_shape_map(mobject)
    target_map = self.get_shape_map(target_mobject)
    if (key_map is None):
        key_map = {}
    transform_source = group_type()
    transform_target = group_type()
    kwargs['final_alpha_value'] = 0
    for key in set(source_map).intersection(target_map):
        transform_source.add(source_map[key])
        transform_target.add(target_map[key])
    anims = [Transform(transform_source, transform_target, **kwargs)]
    key_mapped_source = group_type()
    key_mapped_target = group_type()
    for (key1, key2) in key_map.items():
        if ((key1 in source_map) and (key2 in target_map)):
            key_mapped_source.add(source_map[key1])
            key_mapped_target.add(target_map[key2])
            source_map.pop(key1, None)
            target_map.pop(key2, None)
    if (len(key_mapped_source) > 0):
        anims.append(FadeTransformPieces(key_mapped_source, key_mapped_target, **kwargs))
    fade_source = group_type()
    fade_target = group_type()
    for key in set(source_map).difference(target_map):
        fade_source.add(source_map[key])
    for key in set(target_map).difference(source_map):
        fade_target.add(target_map[key])
    if transform_mismatches:
        if ('replace_mobject_with_target_in_scene' not in kwargs):
            kwargs['replace_mobject_with_target_in_scene'] = True
        anims.append(Transform(fade_source, fade_target, **kwargs))
    elif fade_transform_mismatches:
        anims.append(FadeTransformPieces(fade_source, fade_target, **kwargs))
    else:
        anims.append(FadeOut(fade_source, target_position=fade_target, **kwargs))
        anims.append(FadeIn(fade_target.copy(), target_position=fade_target, **kwargs))
    super().__init__(*anims)
    self.to_remove = mobject
    self.to_add = target_mobject