code: def get_checkpoint_path(path):
      """
      Work around TF problems in checkpoint path handling.
  
      Args:
          path: a user-input path
      Returns:
          str: the argument that can be passed to `tf.train.NewCheckpointReader`
      """
      if os.path.basename(path) == path:
          path = os.path.join(".", path)  # avoid #4921 and #6142
      if os.path.basename(path) == "checkpoint":
          assert tfv1.gfile.Exists(path), path
          path = tfv1.train.latest_checkpoint(os.path.dirname(path))
          # to be consistent with either v1 or v2
  
      # fix paths if provided a wrong one
      new_path = path
      if "00000-of-00001" in path:
          new_path = path.split(".data")[0]
      elif path.endswith(".index"):
          new_path = path.split(".index")[0]
      if new_path != path:
          logger.info(
              "Checkpoint path {} is auto-corrected to {}.".format(
                  path, new_path
              )
          )
          path = new_path
      assert tfv1.gfile.Exists(path) or tfv1.gfile.Exists(
          path + ".index"
      ), path
      return path
  
imports: import glob
  import operator
  import numpy
  import os
  import pprint
  import six
  import tensorflow
  from ..compat import tfv1
  from ..utils import logger
  from .common import get_op_tensor_name
label_desc: Use image node_id 4 for calling a global function with example usage: get_checkpoint_path(path) and returns: path