class_docstr: The base class of PaddleHub Module, users can inherit this class to implement to realize custom class.
class_docstr_tok: ["The","base","class","of","PaddleHub","Module",",","users","can","inherit","this","class","to","implement","to","realize","custom","class","."]
docstr: Export the model to Paddle Inference format.
  
  Args:
      dirname(str): The directory to save the paddle inference model.
      model_filename(str): The name of the saved model file. Default to `__model__`.
      params_filename(str): The name of the saved parameters file, only takes effect when `combined` is True.
          Default to `__params__`.
      input_spec(list): Describes the input of the saved model's forward method, which can be described by
          InputSpec or example Tensor. If None, all input variables of the original Layer's forward method
          would be the inputs of the saved model. Default None.
      include_sub_modules(bool): Whether to export sub modules. Default to True.
      combined(bool): Whether to save all parameters in a combined file. Default to True.
docstr_tok: ["Export","the","model","to","Paddle","Inference","format",".","Args",":","dirname","(","str",")",":","The","directory","to","save","the","paddle","inference","model",".","model_filename","(","str",")",":","The","name","of","the","saved","model","file",".","Default","to","`","__model__","`",".","params_filename","(","str",")",":","The","name","of","the","saved","parameters","file",",","only","takes","effect","when","`","combined","`","is","True",".","Default","to","`","__params__","`",".","input_spec","(","list",")",":","Describes","the","input","of","the","saved","model","'s","forward","method",",","which","can","be","described","by","InputSpec","or","example","Tensor",".","If","None",",","all","input","variables","of","the","original","Layer","'s","forward","method","would","be","the","inputs","of","the","saved","model",".","Default","None",".","include_sub_modules","(","bool",")",":","Whether","to","export","sub","modules",".","Default","to","True",".","combined","(","bool",")",":","Whether","to","save","all","parameters","in","a","combined","file",".","Default","to","True","."]
code: def save_inference_model(
      self,
      dirname: str,
      model_filename: str = None,
      params_filename: str = None,
      input_spec: List[paddle.static.InputSpec] = None,
      include_sub_modules: bool = True,
      combined: bool = True,
  ):
      """
      Export the model to Paddle Inference format.
  
      Args:
          dirname(str): The directory to save the paddle inference model.
          model_filename(str): The name of the saved model file. Default to `__model__`.
          params_filename(str): The name of the saved parameters file, only takes effect when `combined` is True.
              Default to `__params__`.
          input_spec(list): Describes the input of the saved model's forward method, which can be described by
              InputSpec or example Tensor. If None, all input variables of the original Layer's forward method
              would be the inputs of the saved model. Default None.
          include_sub_modules(bool): Whether to export sub modules. Default to True.
          combined(bool): Whether to save all parameters in a combined file. Default to True.
      """
      if include_sub_modules:
          for key, _sub_module in self.sub_modules().items():
              try:
                  sub_dirname = os.path.normpath(
                      os.path.join(dirname, key)
                  )
                  _sub_module.save_inference_model(
                      sub_dirname,
                      include_sub_modules=include_sub_modules,
                      model_filename=model_filename,
                      params_filename=params_filename,
                      combined=combined,
                  )
              except:
                  utils.record_exception(
                      "Failed to save sub module {}".format(
                          _sub_module.name
                      )
                  )
  
      if isinstance(self, paddle.nn.Layer):
          save_file = os.path.join(dirname, "{}".format(self.name))
          if not input_spec:
              if hasattr(self, "input_spec"):
                  input_spec = self.input_spec
              else:
                  _type = self.type.lower()
                  if _type.startswith("cv/image"):
                      input_spec = [
                          paddle.static.InputSpec(
                              shape=[None, 3, None, None],
                              dtype="float32",
                          )
                      ]
                  else:
                      raise RuntimeError(
                          "Module {} lacks `input_spec`, please specify it when calling `save_inference_model`.".format(
                              self.name
                          )
                      )
  
          net = paddle.jit.to_static(self, input_spec)
          paddle.jit.save(net, save_file)
  
          log.logger.info(
              "Paddle Inference model saved in {}.".format(dirname)
          )
          return
  
      if not self._pretrained_model_path:
          raise RuntimeError(
              "Module {} does not support exporting models in Paddle Inference format.".format(
                  self.name
              )
          )
      elif not os.path.exists(
          self._pretrained_model_path
      ) and not os.path.exists(
          self._pretrained_model_path + ".pdmodel"
      ):
          log.logger.warning(
              "The model path of Module {} does not exist.".format(
                  self.name
              )
          )
          return
  
      place = paddle.CPUPlace()
      exe = paddle.static.Executor(place)
  
      _model_filename = None
      _params_filename = None
  
      if os.path.exists(
          os.path.join(self._pretrained_model_path, "model")
      ):
          _model_filename = "model"
  
      if os.path.exists(
          os.path.join(self._pretrained_model_path, "params")
      ):
          _params_filename = "params"
  
      if os.path.exists(
          os.path.join(self._pretrained_model_path, "__params__")
      ):
          _params_filename = "__params__"
      if _model_filename is not None and _params_filename is not None:
          (
              program,
              feeded_var_names,
              target_vars,
          ) = paddle.static.load_inference_model(
              self._pretrained_model_path,
              executor=exe,
              model_filename=_model_filename,
              params_filename=_params_filename,
          )
      else:
          (
              program,
              feeded_var_names,
              target_vars,
          ) = paddle.static.load_inference_model(
              self._pretrained_model_path, executor=exe
          )
  
      global_block = program.global_block()
      feed_vars = [global_block.var(item) for item in feeded_var_names]
  
      path_prefix = dirname
      if os.path.isdir(dirname):
          path_prefix = os.path.join(dirname, "model")
      paddle.static.save_inference_model(
          path_prefix,
          feed_vars=feed_vars,
          fetch_vars=target_vars,
          executor=exe,
          program=program,
      )
  
      log.logger.info(
          "Paddle Inference model saved in {}.".format(dirname)
      )
  
imports: import ast
  import builtins
  import codecs
  import inspect
  import os
  import re
  import sys
  from typing import Callable
  from typing import Generic
  from typing import List
  from typing import Optional
  from typing import Union
  import paddle
  import paddle2onnx
  from easydict import EasyDict
  from paddlehub.compat import paddle_utils
  from paddlehub.compat.module.module_v1 import ModuleV1
  from paddlehub.utils import log
  from paddlehub.utils import parser
  from paddlehub.utils import utils
label_desc: Use image node_id 11 for calling the RunModule obj's underlying member method code with example usage: obj.save_inference_model(dirname, model_filename, params_filename, input_spec, include_sub_modules, combined) without return types