def METHOD_NAME():
    dem = options["input"]
    tri = options["output"]
    size = int(options["size"])
    exponent = float(options["exponent"])
    processes = int(options["processes"])
    circular = flags["c"]
    radius = int((size - 1) / 2)
    region = Region()
    # Some checks
    if "@" in tri:
        tri = tri.split("@")[0]
    if processes == 0:
        gs.fatal("Number of processing cores for parallel computation must not equal 0")
    if processes < 0:
        system_cores = mp.cpu_count()
        processes = system_cores + processes + 1
    if processes > 1:
        if gs.find_program("r.mapcalc.tiled") is False:
            gs.fatal(
                "The GRASS addon r.mapcalc.tiled must also be installed if n_jobs != 1. Run 'g.extension r.mapcalc.tiled'"
            )
    if size <= 2 or size > 51:
        gs.fatal("size must be > 2 and <= 51")
    if size % 2 != 1:
        gs.fatal("size must be an odd number")
    if exponent < 0 or exponent > 4.0:
        gs.fatal("exponent must be >= 0 and <= 4.0")
    # Calculate TRI based on map calc statements
    gs.message("Calculating the Topographic Ruggedness Index...")
    # Generate a list of spatial neighbourhood offsets for the chosen radius
    # ignoring the center cell
    offsets = focal_expr(radius, circular)
    weights = idw_weights(radius, exponent, circular)
    terms = []
    for d, w in zip(offsets, weights):
        d_str = ",".join(map(str, d))
        terms.append("{w}*abs({dem}[{d}]-{dem})".format(dem=dem, d=d_str, w=w))
    # Define the calculation expression
    terms = "+".join(terms)
    # Perform the r.mapcalc calculation with the moving window
    expr = "{tri} = float({terms})".format(tri=tri, terms=terms)
    width, height = tile_shape(region, processes)
    if width < region.cols and height < region.rows and processes > 1:
        gr.mapcalc_tiled(
            expression=expr,
            width=width,
            height=height,
            processes=processes,
            overlap=int((size + 1) / 2),
            output=tri,
        )
    else:
        gs.mapcalc(expr)
    # update metadata
    opts = ""
    if circular:
        opts = "-c"
    gr.support(
        map=tri,
        title="Terrain Ruggedness Index",
        description="Generated with r.tri input={dem} output={tri} size={size} exponent={exponent} {flags}".format(
            dem=dem, tri=tri, size=size, exponent=exponent, flags=opts
        ),
    )
    return 0