def shardformer_t5(t5: T5EncoderModel) -> T5EncoderModel:
    """
    Shardformer for T5 model

    Args:
        t5: T5 model to be optimized

    Returns:
        optimized T5 model
    """
    dtype = t5.shared.weight.dtype
    shard_config = ShardConfig(
        enable_tensor_parallelism=False,
        enable_jit_fused=True,
    )
    shard_former = ShardFormer(shard_config=shard_config)
    optim_model, _ = shard_former.optimize(t5, policy=T5EncoderPolicy())
    optim_model = optim_model.to(dtype).eval().requires_grad_(False)
    return optim_model

    Shardformer for T5 model

    Args:
        t5: T5 model to be optimized

    Returns:
        optimized T5 model
    
opensora/models/text/conditioner.py