pub fn new<'p, P>(model_type: ModelType, p: P, config: &ConfigOption) -> Self
    where
        P: Borrow<nn::Path<'p>>,
    {
        match model_type {
            ModelType::Bert => {
                if let ConfigOption::Bert(config) = config {
                    SequenceClassificationOption::Bert(BertForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Bert!");
                }
            }
            ModelType::DistilBert => {
                if let ConfigOption::DistilBert(config) = config {
                    SequenceClassificationOption::DistilBert(DistilBertModelClassifier::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a DistilBertConfig for DistilBert!");
                }
            }
            ModelType::Roberta => {
                if let ConfigOption::Bert(config) = config {
                    SequenceClassificationOption::Roberta(RobertaForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Roberta!");
                }
            }
            ModelType::XLMRoberta => {
                if let ConfigOption::Bert(config) = config {
                    SequenceClassificationOption::XLMRoberta(RobertaForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Roberta!");
                }
            }
            ModelType::Albert => {
                if let ConfigOption::Albert(config) = config {
                    SequenceClassificationOption::Albert(AlbertForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply an AlbertConfig for Albert!");
                }
            }
            ModelType::Bart => {
                if let ConfigOption::Bart(config) = config {
                    SequenceClassificationOption::Bart(BartForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Bert!");
                }
            }
            ModelType::Electra => {
                panic!("SequenceClassification not implemented for Electra!");
            }
            ModelType::Marian => {
                panic!("SequenceClassification not implemented for Marian!");
            }
            ModelType::T5 => {
                panic!("SequenceClassification not implemented for T5!");
            }
        }
    }
/// Instantiate a new sequence classification model of the supplied type.
///
/// # Arguments
///
/// * `model_type` - `ModelType` indicating the model type to load (must match with the actual data to be loaded)
/// * `p` - `tch::nn::Path` path to the model file to load (e.g. model.ot)
/// * `config` - A configuration (the model type of the configuration must be compatible with the value for
/// `model_type`)
Instantiate a new sequence classification model of the supplied type.
Instantiate a new sequence classification model of the supplied type .
pub fn new<'p, P>(model_type: ModelType, p: P, config: &ConfigOption) -> Self
    where
        P: Borrow<nn::Path<'p>>,
    {
        match model_type {
            ModelType::Bert => {
                if let ConfigOption::Bert(config) = config {
                    SequenceClassificationOption::Bert(BertForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Bert!");
                }
            }
            ModelType::DistilBert => {
                if let ConfigOption::DistilBert(config) = config {
                    SequenceClassificationOption::DistilBert(DistilBertModelClassifier::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a DistilBertConfig for DistilBert!");
                }
            }
            ModelType::Roberta => {
                if let ConfigOption::Bert(config) = config {
                    SequenceClassificationOption::Roberta(RobertaForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Roberta!");
                }
            }
            ModelType::XLMRoberta => {
                if let ConfigOption::Bert(config) = config {
                    SequenceClassificationOption::XLMRoberta(RobertaForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Roberta!");
                }
            }
            ModelType::Albert => {
                if let ConfigOption::Albert(config) = config {
                    SequenceClassificationOption::Albert(AlbertForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply an AlbertConfig for Albert!");
                }
            }
            ModelType::Bart => {
                if let ConfigOption::Bart(config) = config {
                    SequenceClassificationOption::Bart(BartForSequenceClassification::new(
                        p, config,
                    ))
                } else {
                    panic!("You can only supply a BertConfig for Bert!");
                }
            }
            ModelType::Electra => {
                panic!("SequenceClassification not implemented for Electra!");
            }
            ModelType::Marian => {
                panic!("SequenceClassification not implemented for Marian!");
            }
            ModelType::T5 => {
                panic!("SequenceClassification not implemented for T5!");
            }
        }
    }
pub fn new < ' p , P > ( model_type : ModelType , p : P , config : & ConfigOption ) -> Self where P : Borrow < nn :: Path < ' p > > , { match model_type { ModelType :: Bert => { if let ConfigOption :: Bert ( config ) = config { SequenceClassificationOption :: Bert ( BertForSequenceClassification :: new ( p , config , ) ) } else { panic ! ( " " ) ; } } ModelType :: DistilBert => { if let ConfigOption :: DistilBert ( config ) = config { SequenceClassificationOption :: DistilBert ( DistilBertModelClassifier :: new ( p , config , ) ) } else { panic ! ( " " ) ; } } ModelType :: Roberta => { if let ConfigOption :: Bert ( config ) = config { SequenceClassificationOption :: Roberta ( RobertaForSequenceClassification :: new ( p , config , ) ) } else { panic ! ( " " ) ; } } ModelType :: XLMRoberta => { if let ConfigOption :: Bert ( config ) = config { SequenceClassificationOption :: XLMRoberta ( RobertaForSequenceClassification :: new ( p , config , ) ) } else { panic ! ( " " ) ; } } ModelType :: Albert => { if let ConfigOption :: Albert ( config ) = config { SequenceClassificationOption :: Albert ( AlbertForSequenceClassification :: new ( p , config , ) ) } else { panic ! ( " " ) ; } } ModelType :: Bart => { if let ConfigOption :: Bart ( config ) = config { SequenceClassificationOption :: Bart ( BartForSequenceClassification :: new ( p , config , ) ) } else { panic ! ( " " ) ; } } ModelType :: Electra => { panic ! ( " " ) ; } ModelType :: Marian => { panic ! ( " " ) ; } ModelType :: T5 => { panic ! ( " " ) ; } } }
Instantiate a new sequence classification model of the supplied type.
Instantiate a new sequence classification model of the supplied type .
model_type
ModelType
p
P
config
&ConfigOption
model_type
ModelType
p
P
config
&ConfigOption