def gopen(path):
  """Opens a file object given a (possibly gzipped) `path`."""
  logging.info("*** Loading from: %s ***", path)
  if ".gz" in path:
    return gzip.GzipFile(fileobj=tf.gfile.Open(path, "rb"))  # pytype: disable=wrong-arg-types
  else:
    return tf.gfile.Open(path, "r")
Opens a file object given a (possibly gzipped) `path`.
language/canine/tydiqa/tf_io.py