class_docstr: Pyramid Scene Parsing Network.
  
  This is a PSPNet [#]_ model for semantic segmentation. This is based on
  the implementation found here_.
  
  .. [#] Hengshuang Zhao, Jianping Shi, Xiaojuan Qi, Xiaogang Wang     Jiaya Jia "Pyramid Scene Parsing Network"     CVPR, 2017
  
  .. _here: https://github.com/hszhao/PSPNet
  
  Args:
      n_class (int): The number of channels in the last convolution layer.
      pretrained_model (string): The weight file to be loaded.
          This can take :obj:`'cityscapes'`, `filepath` or :obj:`None`.
          The default value is :obj:`None`.
          * :obj:`'cityscapes'`: Load weights trained on the train split of                 Cityscapes dataset.                 :obj:`n_class` must be :obj:`19` or :obj:`None`.
          * :obj:`'ade20k'`: Load weights trained on the train split of                 ADE20K dataset.                 :obj:`n_class` must be :obj:`150` or :obj:`None`.
          * :obj:`'imagenet'`: Load ImageNet pretrained weights for                 the extractor.
          * `filepath`: A path of npz file. In this case, :obj:`n_class`                 must be specified properly.
          * :obj:`None`: Do not load weights.
      input_size (tuple): The size of the input.
          This value is :math:`(height, width)`.
      initialW (callable): Initializer for the weights of
          convolution kernels.
class_docstr_tok: ["Pyramid","Scene","Parsing","Network",".","This","is","a","PSPNet","[","#","]","_","model","for","semantic","segmentation",".","This","is","based","on","the","implementation","found","here_",".","..","[","#","]","Hengshuang","Zhao",",","Jianping","Shi",",","Xiaojuan","Qi",",","Xiaogang","Wang","Jiaya","Jia","``","Pyramid","Scene","Parsing","Network","''","CVPR",",","2017","..","_here",":","https",":","\/\/github.com\/hszhao\/PSPNet","Args",":","n_class","(","int",")",":","The","number","of","channels","in","the","last","convolution","layer",".","pretrained_model","(","string",")",":","The","weight","file","to","be","loaded",".","This","can","take",":","obj",":","`","'cityscapes","'","`",",","`","filepath","`","or",":","obj",":","`","None","`",".","The","default","value","is",":","obj",":","`","None","`",".","*",":","obj",":","`","'cityscapes","'","`",":","Load","weights","trained","on","the","train","split","of","Cityscapes","dataset",".",":","obj",":","`","n_class","`","must","be",":","obj",":","`","19","`","or",":","obj",":","`","None","`",".","*",":","obj",":","`","'ade20k","'","`",":","Load","weights","trained","on","the","train","split","of","ADE20K","dataset",".",":","obj",":","`","n_class","`","must","be",":","obj",":","`","150","`","or",":","obj",":","`","None","`",".","*",":","obj",":","`","'imagenet","'","`",":","Load","ImageNet","pretrained","weights","for","the","extractor",".","*","`","filepath","`",":","A","path","of","npz","file",".","In","this","case",",",":","obj",":","`","n_class","`","must","be","specified","properly",".","*",":","obj",":","`","None","`",":","Do","not","load","weights",".","input_size","(","tuple",")",":","The","size","of","the","input",".","This","value","is",":","math",":","`","(","height",",","width",")","`",".","initialW","(","callable",")",":","Initializer","for","the","weights","of","convolution","kernels","."]
code: def __init__(
      self,
      n_class=None,
      pretrained_model=None,
      input_size=None,
      initialW=None,
  ):
      super(PSPNet, self).__init__()
  
      if pretrained_model == "imagenet":
          extractor_pretrained_model = "imagenet"
          pretrained_model = None
      else:
          extractor_pretrained_model = None
  
      param, path = utils.prepare_pretrained_model(
          {"n_class": n_class, "input_size": input_size},
          pretrained_model,
          self._models,
          default={"input_size": (713, 713)},
      )
      n_class = param["n_class"]
      input_size = param["input_size"]
      if not isinstance(input_size, (list, tuple)):
          input_size = (int(input_size), int(input_size))
      self.input_size = input_size
  
      if initialW is None:
          if pretrained_model:
              initialW = initializers.constant.Zero()
  
      kwargs = self._extractor_kwargs
      kwargs.update(
          {
              "pretrained_model": extractor_pretrained_model,
              "initialW": initialW,
          }
      )
      extractor = self._extractor_cls(**kwargs)
      extractor.pick = self._extractor_pick
  
      self.scales = None
      self.mean = _imagenet_mean
  
      pyramids = [6, 3, 2, 1]
      feat_size = (input_size[0] // 8, input_size[1] // 8)
      with self.init_scope():
          self.extractor = extractor
          self.ppm = PyramidPoolingModule(
              2048, feat_size, pyramids, initialW=initialW
          )
          self.head_conv1 = Conv2DBNActiv(
              4096, 512, 3, 1, 1, initialW=initialW
          )
          self.head_conv2 = L.Convolution2D(
              512, n_class, 1, 1, 0, False, initialW
          )
  
      if path:
          chainer.serializers.load_npz(path, self)
  
imports: from __future__ import division
  from math import ceil
  import numpy
  import chainer
  import chainer.functions
  from chainer import initializers
  import chainer.links
  from chainercv.experimental.links.model.pspnet.transforms import convolution_crop
  from chainercv.links import Conv2DBNActiv
  from chainercv.links.model.resnet import ResBlock
  from chainercv.links import PickableSequentialChain
  from chainercv import transforms
  from chainercv import utils
label_desc: Use image node_id 1 to create a new PSPNet object from inherited base classes: chainer with example: obj = PSPNet(n_class, pretrained_model, input_size, initialW)