code: def _compute_bef(x: Tensor, block_size: int = 8) -> Tensor:
      """Compute block effect.
  
      Args:
          x: input image
          block_size: integer indication the block size
  
      Returns:
          Computed block effect
  
      Raises:
          ValueError:
              If the image is not a grayscale image
  
      """
      (
          _,
          channels,
          height,
          width,
      ) = x.shape
      if channels > 1:
          raise ValueError(
              f"`psnrb` metric expects grayscale images, but got images with {channels} channels."
          )
  
      h = torch.arange(width - 1)
      h_b = torch.tensor(range(block_size - 1, width - 1, block_size))
      h_bc = torch.tensor(
          list(set(h.tolist()).symmetric_difference(h_b.tolist()))
      )
  
      v = torch.arange(height - 1)
      v_b = torch.tensor(range(block_size - 1, height - 1, block_size))
      v_bc = torch.tensor(
          list(set(v.tolist()).symmetric_difference(v_b.tolist()))
      )
  
      d_b = (x[:, :, :, h_b] - x[:, :, :, h_b + 1]).pow(2.0).sum()
      d_bc = (x[:, :, :, h_bc] - x[:, :, :, h_bc + 1]).pow(2.0).sum()
      d_b += (x[:, :, v_b, :] - x[:, :, v_b + 1, :]).pow(2.0).sum()
      d_bc += (x[:, :, v_bc, :] - x[:, :, v_bc + 1, :]).pow(2.0).sum()
  
      n_hb = height * (width / block_size) - 1
      n_hbc = (height * (width - 1)) - n_hb
      n_vb = width * (height / block_size) - 1
      n_vbc = (width * (height - 1)) - n_vb
      d_b /= n_hb + n_vb
      d_bc /= n_hbc + n_vbc
      t = (
          math.log2(block_size) / math.log2(min(height, width))
          if d_b > d_bc
          else 0
      )
      return t * (d_b - d_bc)
  
imports: import math
  from typing import Tuple
  import torch
  from torch import Tensor, tensor
label_desc: Use image node_id 1 for calling a global function with example usage: _compute_bef(x, block_size) and returns: unknown