pub fn new<'p, P>(p: P, config: &ElectraConfig) -> ElectraDiscriminatorHead
    where
        P: Borrow<nn::Path<'p>>,
    {
        let p = p.borrow();

        let dense = nn::linear(
            p / "dense",
            config.hidden_size,
            config.hidden_size,
            Default::default(),
        );
        let dense_prediction = nn::linear(
            p / "dense_prediction",
            config.hidden_size,
            1,
            Default::default(),
        );
        let activation = Box::new(match &config.hidden_act {
            Activation::gelu => _gelu,
            Activation::relu => _relu,
            Activation::mish => _mish,
        });
        ElectraDiscriminatorHead {
            dense,
            dense_prediction,
            activation,
        }
    }
/// Build a new `ElectraDiscriminatorHead`
///
/// # Arguments
///
/// * `p` - Variable store path for the root of the Electra model
/// * `config` - `ElectraConfig` object defining the model architecture
///
/// # Example
///
/// ```no_run
/// use rust_bert::electra::{ElectraConfig, ElectraDiscriminatorHead};
/// use rust_bert::Config;
/// use std::path::Path;
/// use tch::{nn, Device};
///
/// let config_path = Path::new("path/to/config.json");
/// let device = Device::Cpu;
/// let p = nn::VarStore::new(device);
/// let config = ElectraConfig::from_file(config_path);
/// let discriminator_head = ElectraDiscriminatorHead::new(&p.root() / "electra", &config);
/// ```
Build a new `ElectraDiscriminatorHead`
Build a new ` ElectraDiscriminatorHead `
pub fn new<'p, P>(p: P, config: &ElectraConfig) -> ElectraDiscriminatorHead
    where
        P: Borrow<nn::Path<'p>>,
    {
        let p = p.borrow();
        let dense = nn::linear(
            p / "dense",
            config.hidden_size,
            config.hidden_size,
            Default::default(),
        );
        let dense_prediction = nn::linear(
            p / "dense_prediction",
            config.hidden_size,
            1,
            Default::default(),
        );
        let activation = Box::new(match &config.hidden_act {
            Activation::gelu => _gelu,
            Activation::relu => _relu,
            Activation::mish => _mish,
        });
        ElectraDiscriminatorHead {
            dense,
            dense_prediction,
            activation,
        }
    }
pub fn new < ' p , P > ( p : P , config : & ElectraConfig ) -> ElectraDiscriminatorHead where P : Borrow < nn :: Path < ' p > > , { let p = p . borrow ( ) ; let dense = nn :: linear ( p / " " , config . hidden_size , config . hidden_size , Default :: default ( ) , ) ; let dense_prediction = nn :: linear ( p / " " , config . hidden_size , 1 , Default :: default ( ) , ) ; let activation = Box :: new ( match & config . hidden_act { Activation :: gelu => _gelu , Activation :: relu => _relu , Activation :: mish => _mish , } ) ; ElectraDiscriminatorHead { dense , dense_prediction , activation , } }
Build a new `ElectraDiscriminatorHead`
Build a new ` ElectraDiscriminatorHead `
p
P
config
&ElectraConfig
p
P
config
&ElectraConfig
example
```no_run
use rust_bert::electra::{ElectraConfig, ElectraDiscriminatorHead};
use rust_bert::Config;
use std::path::Path;
use tch::{nn, Device}.

let config_path = Path::new("path/to/config.json");
let device = Device::Cpu;
let p = nn::VarStore::new(device);
let config = ElectraConfig::from_file(config_path);
let discriminator_head = ElectraDiscriminatorHead::new(&p.root() / "electra", &config);
```
` ` ` no_run use rust_bert :: electra :: { ElectraConfig ElectraDiscriminatorHead } ; use rust_bert :: Config ; use std :: path :: Path ; use tch :: { nn Device } . let config_path = Path :: new ( " path / to / config . json " ) ; let device = Device :: Cpu ; let p = nn :: VarStore :: new ( device ) ; let config = ElectraConfig :: from_file ( config_path ) ; let discriminator_head = ElectraDiscriminatorHead :: new ( &p . root () / " electra " &config ) ; ` ` `