def create_trainer(config):
    """Create and initialize a trainer instance with the given config.
    
    Args:
        config: Configuration object with training parameters
        
    Returns:
        FSDPSFTTrainer: Initialized trainer instance
    """
    local_rank, rank, world_size = initialize_global_process_group()

    device_mesh = init_device_mesh(device_type='cuda', mesh_shape=(world_size,), mesh_dim_names=('fsdp',))

    dp_size = world_size // config.ulysses_sequence_parallel_size
    ulysses_device_mesh = init_device_mesh(device_type='cuda',
                                           mesh_shape=(dp_size, config.ulysses_sequence_parallel_size),
                                           mesh_dim_names=('dp', 'sp'))

    return FSDPSFTTrainer(config=config, device_mesh=device_mesh, ulysses_device_mesh=ulysses_device_mesh)
Create and initialize a trainer instance with the given config.
    
    Args:
        config: Configuration object with training parameters
        
    Returns:
        FSDPSFTTrainer: Initialized trainer instance
    
tests/sft/test_sp_loss_match.py