code: def _truncate_explanation(
      input_lines, max_lines=None, max_chars=None
  ):
      """
      Truncate given list of strings that makes up the assertion explanation.
  
      Truncates to either 8 lines, or 640 characters - whichever the input reaches
      first. The remaining lines will be replaced by a usage message.
      """
  
      if max_lines is None:
          max_lines = DEFAULT_MAX_LINES
      if max_chars is None:
          max_chars = DEFAULT_MAX_CHARS
  
      # Check if truncation required
      input_char_count = len("".join(input_lines))
      if (
          len(input_lines) <= max_lines
          and input_char_count <= max_chars
      ):
          return input_lines
  
      # Truncate first to max_lines, and then truncate to max_chars if max_chars
      # is exceeded.
      truncated_explanation = input_lines[:max_lines]
      truncated_explanation = _truncate_by_char_count(
          truncated_explanation, max_chars
      )
  
      # Add ellipsis to final line
      truncated_explanation[-1] = truncated_explanation[-1] + "..."
  
      # Append useful message to explanation
      truncated_line_count = len(input_lines) - len(
          truncated_explanation
      )
      truncated_line_count += (
          1  # Account for the part-truncated final line
      )
      msg = "...Full output truncated"
      if truncated_line_count == 1:
          msg += " ({} line hidden)".format(truncated_line_count)
      else:
          msg += " ({} lines hidden)".format(truncated_line_count)
      msg += ", {}".format(USAGE_MSG)
      truncated_explanation.extend(
          [six.text_type(""), six.text_type(msg)]
      )
      return truncated_explanation
  
file_path: catboost/contrib/python/pytest/py2/_pytest/assertion/truncate.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import six
label_desc: Use image node_id 4 for calling a global function with example usage: _truncate_explanation(input_lines, max_lines, max_chars) and returns: truncated_explanation, input_lines