code: def post_process_repr(repr_, n_char_max):
      """Post-process repr produced by _StepPrettyPrinter.
      Adapted from the original in scikit-learn BaseEstimator.__repr__
      """
      # Use bruteforce ellipsis when there are a lot of non-blank characters
      n_nonblank = len("".join(repr_.split()))
      if n_nonblank > n_char_max:
          lim = (
              n_char_max // 2
          )  # apprx number of chars to keep on both ends
          regex = r"^(\s*\S){%d}" % lim
          # The regex '^(\s*\S){%d}' % n
          # matches from the start of the string until the nth non-blank
          # character:
          # - ^ matches the start of string
          # - (pattern){n} matches n repetitions of pattern
          # - \s*\S matches a non-blank char following zero or more blanks
          left_lim = re.match(regex, repr_).end()
          right_lim = re.match(regex, repr_[::-1]).end()
  
          if "\n" in repr_[left_lim:-right_lim]:
              # The left side and right side aren't on the same line.
              # To avoid weird cuts, e.g.:
              # categoric...ore',
              # we need to start the right side with an appropriate newline
              # character so that it renders properly as:
              # categoric...
              # handle_unknown='ignore',
              # so we add [^\n]*\n which matches until the next \n
              regex += r"[^\n]*\n"
              right_lim = re.match(regex, repr_[::-1]).end()
  
          ellipsis = "..."
          if left_lim + len(ellipsis) < len(repr_) - right_lim:
              # Only add ellipsis if it results in a shorter repr
              repr_ = repr_[:left_lim] + "..." + repr_[-right_lim:]
      return repr_
  
imports: from inspect import signature
  import numbers
  import pprint
  import re
  from collections import OrderedDict
  import numpy
  from baikal import Step, get_config
label_desc: Use image node_id 5 for calling a global function with example usage: post_process_repr(repr_, n_char_max) and returns: repr_