code: def non_repeating_log_factory(
      logger: logging.Logger, method: str, cache_size=100
  ) -> Callable:
      """Create log function that filters the repeated messages.
  
      By default. It only keeps track of last 100 messages, if a repeated
      message arrives after the ``cache_size`` messages, it will be displayed.
  
      Args:
          logger (logging.Logger): the logger to be used to dispatch the message.
          method (str): the log method, can be info, warning or debug.
          cache_size (int): the number of last log messages to keep in cache.
              Default to 100
  
      Returns:
          (Callable): the new log method
      """
      if method not in ["info", "warning", "debug"]:
          raise ValueError("Not supported logging method.")
  
      _caches = deque(maxlen=cache_size)
      log_method = getattr(logger, method)
  
      def new_log_method(msg, *args, **kwargs):
          key = f"{msg}:{args}"
          if key not in _caches:
              log_method(msg, *args, **kwargs)
              _caches.append(key)
  
      return new_log_method
  
file_path: sagemaker-python-sdk/src/sagemaker/config/config_utils.py
imports: from __future__ import absolute_import
  from collections import deque
  import logging
  import sys
  from typing import Callable
label_desc: Use image node_id 4 for calling a global function with example usage: non_repeating_log_factory(logger, method, cache_size) and returns: new_log_method