Import module at usr_dir, if provided.

def import_usr_dir(usr_dir):
  """Import module at usr_dir, if provided."""
  if not usr_dir:
    return
  if usr_dir == INTERNAL_USR_DIR_PACKAGE:
    # The package has been installed with pip under this name for Cloud ML
    # Engine so just import it.
    importlib.import_module(INTERNAL_USR_DIR_PACKAGE)
    return

  dir_path = os.path.abspath(os.path.expanduser(usr_dir).rstrip("/"))
  containing_dir, module_name = os.path.split(dir_path)
  tf.logging.info("Importing user module %s from path %s", module_name,
                  containing_dir)
  sys.path.insert(0, containing_dir)
  importlib.import_module(module_name)
  sys.path.pop(0)