code: def buffer_to_bytes(buf):
      """Cast a buffer or memoryview object to bytes"""
      if isinstance(buf, memoryview):
          return buf.tobytes()
      if not isinstance(buf, bytes):
          return bytes(buf)
      return buf
  
file_path: catboost/contrib/python/ipython-genutils/py2/ipython_genutils/py3compat.py
imports: import functools
  import os
  import sys
  import re
  import shutil
  import types
  from .encoding import DEFAULT_ENCODING
  import platform
label_desc: Use image node_id 6 for calling a global function with example usage: buffer_to_bytes(buf) and returns: buf, buf, bytes