def _get_num_tiles(self, height, width, tile_height, tile_width, normal_tile_overlap, border_tile_overlap):
        """
        Calculates the number of tiles needed to cover an image, choosing the appropriate formula based on the
        ratio between the image size and the tile size.

        This function automatically selects between two formulas:
        1. A universal formula for typical cases (image-to-tile ratio <= 6:1).
        2. A specialized formula with border tile overlap for larger or atypical cases (image-to-tile ratio > 6:1).

        Args:
            height (int): Height of the image in pixels.
            width (int): Width of the image in pixels.
            tile_height (int): Height of each tile in pixels.
            tile_width (int): Width of each tile in pixels.
            normal_tile_overlap (int): Overlap between tiles in pixels for normal (non-border) tiles.
            border_tile_overlap (int): Overlap between tiles in pixels for border tiles.

        Returns:
            tuple: A tuple containing:
                - grid_rows (int): Number of rows in the tile grid.
                - grid_cols (int): Number of columns in the tile grid.

        Notes:
            - The function uses the universal formula (without border_tile_overlap) for typical cases where the
            image-to-tile ratio is 6:1 or smaller.
            - For larger or atypical cases (image-to-tile ratio > 6:1), it uses a specialized formula that includes
            border_tile_overlap to ensure complete coverage of the image, especially at the edges.
        """
        # Calculate the ratio between the image size and the tile size
        height_ratio = height / tile_height
        width_ratio = width / tile_width

        # If the ratio is greater than 6:1, use the formula with border_tile_overlap
        if height_ratio > 6 or width_ratio > 6:
            grid_rows = int(np.ceil((height - border_tile_overlap) / (tile_height - normal_tile_overlap))) + 1
            grid_cols = int(np.ceil((width - border_tile_overlap) / (tile_width - normal_tile_overlap))) + 1
        else:
            # Otherwise, use the universal formula
            grid_rows = int(np.ceil((height - normal_tile_overlap) / (tile_height - normal_tile_overlap)))
            grid_cols = int(np.ceil((width - normal_tile_overlap) / (tile_width - normal_tile_overlap)))

        return grid_rows, grid_cols

        Calculates the number of tiles needed to cover an image, choosing the appropriate formula based on the
        ratio between the image size and the tile size.

        This function automatically selects between two formulas:
        1. A universal formula for typical cases (image-to-tile ratio <= 6:1).
        2. A specialized formula with border tile overlap for larger or atypical cases (image-to-tile ratio > 6:1).

        Args:
            height (int): Height of the image in pixels.
            width (int): Width of the image in pixels.
            tile_height (int): Height of each tile in pixels.
            tile_width (int): Width of each tile in pixels.
            normal_tile_overlap (int): Overlap between tiles in pixels for normal (non-border) tiles.
            border_tile_overlap (int): Overlap between tiles in pixels for border tiles.

        Returns:
            tuple: A tuple containing:
                - grid_rows (int): Number of rows in the tile grid.
                - grid_cols (int): Number of columns in the tile grid.

        Notes:
            - The function uses the universal formula (without border_tile_overlap) for typical cases where the
            image-to-tile ratio is 6:1 or smaller.
            - For larger or atypical cases (image-to-tile ratio > 6:1), it uses a specialized formula that includes
            border_tile_overlap to ensure complete coverage of the image, especially at the edges.
        
examples/community/mod_controlnet_tile_sr_sdxl.py