code: def from_pretrained(
      cls, pretrain_dir_or_url, force_download=False, **kwargs
  ):
      if (
          not Path(pretrain_dir_or_url).exists()
          and str(pretrain_dir_or_url) in cls.resource_map
      ):
          url = cls.resource_map[str(pretrain_dir_or_url)]
          log.info("get pretrain dir from %s" % url)
          pretrain_dir = _fetch_from_remote(url, force_download)
      else:
          log.info(
              "pretrain dir %s not in %s, read from local"
              % (pretrain_dir_or_url, repr(cls.resource_map))
          )
          pretrain_dir = Path(pretrain_dir_or_url)
  
      if not pretrain_dir.exists():
          raise ValueError(
              "pretrain dir not found: %s, optional: %s"
              % (pretrain_dir, cls.resource_map.keys())
          )
      state_dict_path = pretrain_dir / "saved_weights.pdparams"
      config_path = pretrain_dir / "ernie_config.json"
  
      if not config_path.exists():
          raise ValueError("config path not found: %s" % config_path)
      name_prefix = kwargs.pop("name", None)
      cfg_dict = dict(json.loads(config_path.open().read()), **kwargs)
      model = cls(cfg_dict, name=name_prefix)
  
      log.info("loading pretrained model from %s" % pretrain_dir)
  
      # param_path = pretrain_dir / 'params'
      # if os.path.exists(param_path):
      #    raise NotImplementedError()
      #    log.debug('load pretrained weight from program state')
      #    F.io.load_program_state(param_path) #buggy in dygraph.gurad, push paddle to fix
      if state_dict_path.exists():
          m = P.load(str(state_dict_path))
          for k, v in model.state_dict().items():
              if k not in m:
                  log.warn(
                      "param:%s not set in pretrained model, skip" % k
                  )
                  m[k] = v  # FIXME: no need to do this in the future
          model.set_state_dict(m)
      else:
          raise ValueError(
              "weight file not found in pretrain dir: %s" % pretrain_dir
          )
      return model
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import json
  import logging
  import math
  import six
  import numpy
  import paddle
  from paddle import nn
  from paddle.nn import functional
  from disco_diffusion_ernievil_base.vit_b_16x.ernievil2.transformers.file_utils import _fetch_from_remote, add_docstring
label_desc: Use image node_id 1 for calling the PretrainedModel obj's underlying member method code with example usage: obj.from_pretrained(cls, pretrain_dir_or_url, force_download) and returns: model