def METHOD_NAME(obj, settings, attributes, frame_start=None, frame_end=None):
    if frame_start is None:
        frame_start = bpy.context.scene.frame_start
    if frame_end is None:
        frame_end = bpy.context.scene.frame_end
    mod = obj.modifiers.new('bake_cloth', 'CLOTH')
    mod.settings.effector_weights.gravity = settings.pop('gravity', 1)
    for k, v in settings.items():
        setattr(mod.settings, k, v)
    with butil.DisableModifiers(obj):
        for name, attr in attributes.items():
            vgroup = attribute_to_vertex_group(obj, attr, name=f'skin_sim.{name}')
            setattr(mod.settings, name, vgroup.name)
    mod.point_cache.frame_start = frame_start
    mod.point_cache.frame_end = frame_end
    with butil.ViewportMode(obj, mode='OBJECT'), butil.SelectObjects(obj), Timer('Baking fish cloth'):
        override = {'scene': bpy.context.scene, 'active_object': obj, 'point_cache': mod.point_cache}
        bpy.ops.ptcache.bake(override, bake=True)
    return mod