class_docstr: A convolutional neural network for text classification.
  
  We use different versions of this network to pretrain models for
  text classification.
docstr: Load trained Word CNN model by name or from path.
  
  Args:
      name_or_path (:obj:`str`): Name of the model (e.g. "cnn-imdb") or model saved via :meth:`save_pretrained`.
  Returns:
      :class:`~textattack.models.helpers.WordCNNForClassification` model
docstr_tok: ["Load","trained","Word","CNN","model","by","name","or","from","path",".","Args",":","name_or_path","(",":","obj",":","`","str","`",")",":","Name","of","the","model","(","e.g",".","``","cnn-imdb","''",")","or","model","saved","via",":","meth",":","`","save_pretrained","`",".","Returns",":",":","class",":","`","~textattack.models.helpers.WordCNNForClassification","`","model"]
code: def from_pretrained(cls, name_or_path):
      """Load trained Word CNN model by name or from path.
  
      Args:
          name_or_path (:obj:`str`): Name of the model (e.g. "cnn-imdb") or model saved via :meth:`save_pretrained`.
      Returns:
          :class:`~textattack.models.helpers.WordCNNForClassification` model
      """
      if name_or_path in TEXTATTACK_MODELS:
          path = utils.download_from_s3(TEXTATTACK_MODELS[name_or_path])
      else:
          path = name_or_path
  
      config_path = os.path.join(path, "config.json")
  
      if os.path.exists(config_path):
          with open(config_path, "r") as f:
              config = json.load(f)
      else:
          # Default config
          config = {
              "architectures": "WordCNNForClassification",
              "hidden_size": 150,
              "dropout": 0.3,
              "num_labels": 2,
              "max_seq_length": 128,
              "model_path": None,
              "emb_layer_trainable": True,
          }
      del config["architectures"]
      model = cls(**config)
      state_dict = load_cached_state_dict(path)
      model.load_state_dict(state_dict)
      return model
  
imports: import json
  import os
  import torch
  from torch import nn
  from torch.nn import functional
  import textattack
  from textattack.model_args import TEXTATTACK_MODELS
  from textattack.models.helpers import GloveEmbeddingLayer
  from textattack.models.helpers.utils import load_cached_state_dict
  from textattack.shared import utils
label_desc: Use image node_id 4 for calling the WordCNNForClassification obj's underlying member method code with example usage: obj.from_pretrained(cls, name_or_path) and returns: model