code: def templates_env(filename=None, **kwargs):
      """Return visualization templates directory environment. If filename provided, the exact
      template is being retrieved and provided keyword arguments - rendered accordingly.
  
      :param str filename: the name of the template to get retrieved.
      :param kwargs: residual keyword arguments which would be used for rendering
      :returns: template if a filename is provided (rendered given that keyword arguments are provided)
                otherwise: environment of the templates directory
      """
      if filename:
          if kwargs:
              return _TEMPLATES_ENV.get_template(filename).render(
                  **kwargs
              )
          else:
              return _TEMPLATES_ENV.get_template(filename)
      else:
          return _TEMPLATES_ENV
  
file_path: popmon/popmon/resources.py
imports: import json
  import pathlib
  from jinja2 import Environment, FileSystemLoader
  from pkg_resources import resource_filename
  import popmon
label_desc: Use image node_id 7 for calling a global function with example usage: templates_env(filename) and returns: _TEMPLATES_ENV, _TEMPLATES_ENV, _TEMPLATES_ENV