code: def _truncate_by_char_count(input_lines, max_chars):
      # Check if truncation required
      if len("".join(input_lines)) <= max_chars:
          return input_lines
  
      # Find point at which input length exceeds total allowed length
      iterated_char_count = 0
      for iterated_index, input_line in enumerate(input_lines):
          if iterated_char_count + len(input_line) > max_chars:
              break
          iterated_char_count += len(input_line)
  
      # Create truncated explanation with modified final line
      truncated_result = input_lines[:iterated_index]
      final_line = input_lines[iterated_index]
      if final_line:
          final_line_truncate_point = max_chars - iterated_char_count
          final_line = final_line[:final_line_truncate_point]
      truncated_result.append(final_line)
      return truncated_result
  
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 5 for calling a global function with example usage: _truncate_by_char_count(input_lines, max_chars) and returns: truncated_result, input_lines