def fuse_ln_linear(cls, layernorm: nn.Module, linear_layers: Iterable[nn.Linear]):
        """Fuse the linear operations in Layernorm into the adjacent linear blocks."""
        for linear in linear_layers:
            linear_dtype = linear.weight.dtype

            # Calculating new weight and bias
            W_ = linear.weight.data.double()
            linear.weight.data = (W_ * layernorm.weight.double()).to(linear_dtype)

            if hasattr(layernorm, "bias"):
                if linear.bias is None:
                    linear.bias = nn.Parameter(torch.zeros(linear.out_features, dtype=torch.float64))
                linear.bias.data = linear.bias.data.double() + torch.matmul(W_, layernorm.bias.double())
                linear.bias.data = linear.bias.data.to(linear_dtype)

        # update layernorm weight and bias
        layernorm.weight.data = torch.ones_like(layernorm.weight.data)
        if hasattr(layernorm, "bias"):
            layernorm.bias = None
Fuse the linear operations in Layernorm into the adjacent linear blocks.
olive/passes/pytorch/rotate.py