code: def throw_if_file_access_not_allowed(
      file_path, logdir, allowed_dir=None
  ):
      """Throws an error if a file cannot be loaded for inference.
  
      Args:
        file_path: A file path.
        logdir: The path to the logdir of the TensorBoard context.
        allowed_dir: An optional path to allow loading files from, outside of
        the logdir.
  
      Raises:
        InvalidUserInputError: If the file is not in the logdir and is not globally
            readable.
      """
      file_paths = filepath_to_filepath_list(file_path)
      if not file_paths:
          raise common_utils.InvalidUserInputError(
              file_path + " contains no files"
          )
  
      for path in file_paths:
          # Check if the file is inside the logdir or allowed dir.
          if not (
              path_is_parent(logdir, path)
              or (allowed_dir and path_is_parent(allowed_dir, path))
          ):
              raise common_utils.InvalidUserInputError(
                  path + " is not inside the TensorBoard logdir or "
                  "--whatif-data-dir argument directory."
              )
  
file_path: what-if-tool/utils/platform_utils.py
imports: import csv
  from glob import glob
  from grpc.beta import implementations
  import os
  import random
  from six.moves.urllib.parse import urlparse
  import tensorflow
  from utils import common_utils
  from tensorflow.core.framework import types_pb2
  from tensorflow_serving.apis import classification_pb2
  from tensorflow_serving.apis import predict_pb2
  from tensorflow_serving.apis import prediction_service_pb2
  from tensorflow_serving.apis import regression_pb2
label_desc: Use image node_id 3 for calling a global function with example usage: throw_if_file_access_not_allowed(file_path, logdir, allowed_dir) without return types