docstr: Load templates from static files and the global language files.
  
  Template files: `sklearn_porter/estimator/SVC/templates/<language>/*txt`
  Language files: `sklearn_porter/language/<language>.py`
  
  Parameters
  ----------
  language : str or Language
      The required language.
  
  Returns
  -------
  environment : Environment
      An Jinja environment with all loaded templates.
docstr_tok: ["Load","templates","from","static","files","and","the","global","language","files",".","Template","files",":","`","sklearn_porter\/estimator\/SVC\/templates\/","<","language",">","\/","*","txt","`","Language","files",":","`","sklearn_porter\/language\/","<","language",">",".py","`","Parameters","--","--","--","--","--","language",":","str","or","Language","The","required","language",".","Returns","--","--","--","-","environment",":","Environment","An","Jinja","environment","with","all","loaded","templates","."]
code: def _load_templates(
      self, language: Union[str, enum.Language]
  ) -> Environment:
      """
      Load templates from static files and the global language files.
  
      Template files: `sklearn_porter/estimator/SVC/templates/<language>/*txt`
      Language files: `sklearn_porter/language/<language>.py`
  
      Parameters
      ----------
      language : str or Language
          The required language.
  
      Returns
      -------
      environment : Environment
          An Jinja environment with all loaded templates.
      """
      language = (
          enum.Language[language.upper()].value
          if isinstance(language, str)
          else language
      )
  
      tpls = {}  # Dict
  
      # 1. Load basic language templates (e.g. `if`, `else`, ...):
      lang_tpls = language.TEMPLATES
      if isinstance(language.TEMPLATES, dict):
          tpls.update(lang_tpls)
      L.debug(
          "Load template variables: {}".format(
              ", ".join(lang_tpls.keys())
          )
      )
  
      # 2. Load base language templates (e.g. `base.attached.class`):
      root_dir = Path(__file__).parent.parent
      tpls_dir = root_dir / "language" / language.KEY / "templates"
      if tpls_dir.exists():
          tpls_paths = set(tpls_dir.glob("*.jinja2"))
          tpls.update(
              {path.stem: path.read_text() for path in tpls_paths}
          )
  
      # 3. Load specific templates from template files:
      bases = list(
          set([base.__name__ for base in self.__class__.__bases__])
      )
      if "EstimatorBase" in bases:
          bases.remove("EstimatorBase")
      if "EstimatorApiABC" in bases:
          bases.remove("EstimatorApiABC")
      bases.append(self.__class__.__name__)
      est_dir = root_dir / "estimator"
      for base_dir in bases:
          tpls_dir = est_dir / base_dir / "templates" / language.KEY
          if tpls_dir.exists():
              tpls_paths = set(tpls_dir.glob("*.jinja2"))
              tpls.update(
                  {path.stem: path.read_text() for path in tpls_paths}
              )
  
      L.debug("Load template files: {}".format(", ".join(tpls.keys())))
  
      environment = Environment(
          autoescape=False,
          trim_blocks=True,
          lstrip_blocks=True,
          loader=DictLoader(tpls),
      )
      return environment
  
file_path: sklearn-porter/sklearn_porter/estimator/EstimatorBase.py
imports: from os import environ, getcwd
  from pathlib import Path
  from time import sleep
  from typing import Dict, Optional, Set, Tuple, Union, Callable
  from jinja2 import DictLoader, Environment
  from loguru import logger
  from sklearn import __version__
  from sklearn.base import BaseEstimator
  from sklearn_porter import __version__
  from sklearn_porter import enums
  from sklearn_porter.estimator.EstimatorApiABC import EstimatorApiABC
label_desc: Use image node_id 4 for calling the EstimatorBase obj's underlying member method code with example usage: obj._load_templates(language) and returns: environment