code: def filter_dateformat(
      value: Any,
      fmt: str = "{:%Y-%m-%d %H:%M:%S}",
      freq: Optional[str] = None,
  ) -> str:
      """Jinja filter to format a datetime. If a frequency is provided, uses it to obtain the best
      format, else defers to ``fmt``.
  
      Args:
          value (Any): Datetime to format.
          fmt (str): The datetime format to default to.
          freq (Optional[str]): The respective frequency.
  
      Returns:
          str: Formatted datetime.
      """
      if freq:
          fmt = format_date_freq(freq)
      return fmt.format(value)
  
file_path: tslumen/tslumen/jinja_utils.py
imports: from math import ceil, log10, floor
  from typing import List, Optional, Any, Tuple
  from datetime import datetime
  import re
  import numpy
  import pandas
  import jinja2
label_desc: Use image node_id 5 for calling a global function with example usage: filter_dateformat(value, fmt, freq) and returns: fmt