code: def make_input_stream(input, charset):
      # Is already an input stream.
      if hasattr(input, "read"):
          if PY2:
              return input
          rv = _find_binary_reader(input)
          if rv is not None:
              return rv
          raise TypeError(
              "Could not find binary reader for input stream."
          )
  
      if input is None:
          input = b""
      elif not isinstance(input, bytes):
          input = input.encode(charset)
      if PY2:
          return StringIO(input)
      return io.BytesIO(input)
  
imports: import contextlib
  import os
  import shlex
  import shutil
  import sys
  import tempfile
  from .None import formatting
  from .None import termui
  from .None import utils
  from ._compat import iteritems
  from ._compat import PY2
  from ._compat import string_types
label_desc: Use image node_id 1 for calling a global function with example usage: make_input_stream(input, charset) and returns: io, StringIO, input, rv