code: def read_file_to_string(
      filename: Text, binary_mode: bool = False
  ) -> Union[Text, bytes]:
      """Reads the entire contents of a file to a string.
  
      Args:
        filename: path to a file
        binary_mode: whether to open the file in binary mode or not. This changes
          the type of the object returned.
  
      Returns:
        contents of the file as a string or bytes.
      """
      if binary_mode:
          f = tf.io.gfile.GFile(filename, mode="rb")
      else:
          f = tf.io.gfile.GFile(filename, mode="r")
      return f.read()
  
file_path: data-validation/tensorflow_data_validation/utils/io_util.py
imports: import os
  import pickle
  from typing import Any, Iterator, List, Text, Union
  import uuid
  import apache_beam
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: read_file_to_string(filename, binary_mode) and returns: f