code: def make_input_stream(
      input: t.Optional[t.Union[str, bytes, t.IO[t.Any]]], charset: str
  ) -> t.BinaryIO:
      # Is already an input stream.
      if hasattr(input, "read"):
          rv = _find_binary_reader(t.cast(t.IO[t.Any], 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 isinstance(input, str):
          input = input.encode(charset)
  
      return io.BytesIO(input)
  
imports: import contextlib
  import io
  import os
  import shlex
  import shutil
  import sys
  import tempfile
  import typing
  from types import TracebackType
  from .None import formatting
  from .None import termui
  from .None import utils
  from ._compat import _find_binary_reader
label_desc: Use image node_id 2 for calling a global function with example usage: make_input_stream(input, charset) and returns: io, rv