code: def get_post(id, check_author=True):
      """Get a post and its author by id.
  
      Checks that the id exists and optionally that the current user is
      the author.
  
      :param id: id of post to get
      :param check_author: require the current user to be the author
      :return: the post with author information
      :raise 404: if a post with the given id doesn't exist
      :raise 403: if the current user isn't the author
      """
      post = db.get_or_404(
          Post, id, description=f"Post id {id} doesn't exist."
      )
  
      if check_author and post.author != g.user:
          abort(403)
  
      return post
  
file_path: flask-sqlalchemy/examples/flaskr/flaskr/blog/views.py
imports: from flask import Blueprint
  from flask import flash
  from flask import g
  from flask import redirect
  from flask import render_template
  from flask import request
  from flask import url_for
  from werkzeug.exceptions import abort
  from flaskr import db
  from flaskr.auth.views import login_required
  from flaskr.blog.models import Post
label_desc: Use image node_id 2 for calling a global function with example usage: get_post(id, check_author) and returns: post