class_docstr: Extract image feature using pretrained CNN network.
class_docstr_tok: ["Extract","image","feature","using","pretrained","CNN","network","."]
docstr: Lazily initialize preprocessor model.
  
  When image_mode is one of the ``resnext101_..._wsl`` varieties
docstr_tok: ["Lazily","initialize","preprocessor","model",".","When","image_mode","is","one","of","the","``","resnext101_","...","_wsl","``","varieties"]
code: def _init_resnext_cnn(self):
      """
      Lazily initialize preprocessor model.
  
      When image_mode is one of the ``resnext101_..._wsl`` varieties
      """
      try:
          cnn_type, layer_num = self._image_mode_switcher()
          model = torch.hub.load(
              "facebookresearch/WSL-Images", cnn_type
          )
          # cut off layer for ImageNet classification
          # if spatial, cut off another layer for spatial features
          self.netCNN = torch.nn.Sequential(
              *list(model.children())[:layer_num]
          )
      except RuntimeError as e:
          # Perhaps specified one of the wrong model names
          model_names = [
              m for m in IMAGE_MODE_SWITCHER if "resnext101" in m
          ]
          logging.error(
              "If you have specified one of the resnext101 wsl models, "
              "please make sure it is one of the following: \n"
              f"{', '.join(model_names)}"
          )
          raise e
      except AttributeError:
          # E.g. "module 'torch' has no attribute 'hub'"
          raise RuntimeError(
              "Please install the latest pytorch distribution to have access "
              "to the resnext101 wsl models (pytorch 1.1.0, torchvision 0.3.0)"
          )
  
      if self.use_cuda:
          self.netCNN.cuda()
  
imports: import parlai.core.build_data
  import parlai.utils.logging
  from parlai.utils.io import PathManager
  import os
  from PIL import Image
  import torch
  from zipfile import ZipFile
label_desc: Use image node_id 5 for calling the ImageLoader obj's underlying member method code with example usage: obj._init_resnext_cnn() without return types