code: def load_model(dirpath: typing.Union[str, Path]) -> BaseModel:
      """
      Load a model. The reverse function of :meth:`BaseModel.save`.
  
      :param dirpath: directory path of the saved model
      :return: a :class:`BaseModel` instance
  
      Example:
  
              >>> import matchzoo as mz
              >>> model = mz.models.Naive()
              >>> model.guess_and_fill_missing_params(verbose=0)
              >>> model.build()
              >>> model.save('my-model')
              >>> model.params.keys() == mz.load_model('my-model').params.keys()
              True
              >>> import shutil
              >>> shutil.rmtree('my-model')
  
      """
      dirpath = Path(dirpath)
  
      params_path = dirpath.joinpath(BaseModel.PARAMS_FILENAME)
      weights_path = dirpath.joinpath(
          BaseModel.BACKEND_WEIGHTS_FILENAME
      )
  
      with open(params_path, mode="rb") as params_file:
          params = dill.load(params_file)
  
      model_instance = params["model_class"](params=params)
      model_instance.build()
      model_instance.compile()
      model_instance.backend.load_weights(weights_path)
      return model_instance
  
imports: import abc
  import typing
  from pathlib import Path
  import dill
  import numpy
  import keras
  import keras.backend
  import pandas
  import matchzoo
  from matchzoo import DataGenerator
  from matchzoo.engine import hyper_spaces
  from matchzoo.engine.base_preprocessor import BasePreprocessor
  from matchzoo.engine.base_metric import BaseMetric
  from matchzoo.engine.param_table import ParamTable
  from matchzoo.engine.param import Param
  from matchzoo import tasks
label_desc: Use image node_id 1 for calling a global function with example usage: load_model(dirpath) and returns: model_instance