def _remove_if_name_main_codeblock(file_path: str):
    """Parse the file, remove the gr.no_reload code blocks, and write the file back to disk.

    Parameters:
        file_path (str): The path to the file to remove the no_reload code blocks from.
    """

    with open(file_path, encoding="utf-8") as file:
        code = file.read()

    tree = ast.parse(code)

    def _is_if_name_main(expr: ast.AST) -> bool:
        """Find the if __name__ == '__main__': block."""
        return (
            isinstance(expr, ast.If)
            and isinstance(expr.test, ast.Compare)
            and isinstance(expr.test.left, ast.Name)
            and expr.test.left.id == "__name__"
            and len(expr.test.ops) == 1
            and isinstance(expr.test.ops[0], ast.Eq)
            and isinstance(expr.test.comparators[0], ast.Constant)
            and expr.test.comparators[0].s == "__main__"
        )

    # Find the positions of the code blocks to load
    for node in ast.walk(tree):
        if _is_if_name_main(node):
            assert isinstance(node, ast.If)  # noqa: S101
            node.body = [ast.Pass(lineno=node.lineno, col_offset=node.col_offset)]

    # convert tree to string
    code_removed = compile(tree, filename=file_path, mode="exec")
    return code_removed
Parse the file, remove the gr.no_reload code blocks, and write the file back to disk.

    Parameters:
        file_path (str): The path to the file to remove the no_reload code blocks from.
    
gradio/utils.py