How to call wp-load.php from patterns folder

In function.php

function register_custom_patterns() {
    register_block_pattern(
        'twentytwentyfive/asif', // The pattern slug
        array(
            'title'       => __( 'Test Pattern', 'twentytwentyfive' ),
            'description' => __( 'A custom test pattern for the theme.', 'twentytwentyfive' ),
            'content'     => file_get_contents( get_template_directory_uri() . '/patterns/asif.php'), // Path to your custom PHP file
        )
    );
}
add_action( 'init', 'register_custom_patterns' );

Location of asif.php file

C:xampphtdocsasif_wpwp-contentthemestwentytwentyfivepatternsasif.php

asif.php code

   function asif() {
       echo "Working!";
    }
    add_action( 'init', 'asif' );

After loading Test Pattern in theme

Error:

Fatal error: Uncaught Error: Call to undefined function add_action() in C:xampphtdocsasif_wpwp-contentthemestwentytwentyfivepatternsasif.php:6
Stack trace:
#0 {main}
thrown in C:xampphtdocsasif_wpwp-contentthemestwentytwentyfivepatternsasif.php on line 6    

Then I edited asif.php

<?php
require_once('../../../../wp-load.php');
function asif() {
   echo "Working!";
}
add_action( 'init', 'asif' );

?>

Result:

Browser is loading (waiting) and passing through infinite loop and at the end my computer is hanging