docstr: Convert Bitmasks to tensor.
  
  Args:
      bitmasks (list[BitmapMasks]): The BitmapMasks list. Each item is
          for one img.
      target_sz (tuple(int, int)): The target tensor of size
          :math:`(H, W)`.
  
  Returns:
      list[Tensor]: The list of kernel tensors. Each element stands for
      one kernel level.
docstr_tok: ["Convert","Bitmasks","to","tensor",".","Args",":","bitmasks","(","list","[","BitmapMasks","]",")",":","The","BitmapMasks","list",".","Each","item","is","for","one","img",".","target_sz","(","tuple","(","int",",","int",")",")",":","The","target","tensor","of","size",":","math",":","`","(","H",",","W",")","`",".","Returns",":","list","[","Tensor","]",":","The","list","of","kernel","tensors",".","Each","element","stands","for","one","kernel","level","."]
code: def bitmasks2tensor(self, bitmasks, target_sz):
      """Convert Bitmasks to tensor.
  
      Args:
          bitmasks (list[BitmapMasks]): The BitmapMasks list. Each item is
              for one img.
          target_sz (tuple(int, int)): The target tensor of size
              :math:`(H, W)`.
  
      Returns:
          list[Tensor]: The list of kernel tensors. Each element stands for
          one kernel level.
      """
      batch_size = len(bitmasks)
      results = []
  
      kernel = []
      for batch_inx in range(batch_size):
          mask = bitmasks[batch_inx]
          # hxw
          mask_sz = mask.shape
          # left, right, top, bottom
          pad = [
              0,
              target_sz[1] - mask_sz[1],
              0,
              target_sz[0] - mask_sz[0],
          ]
          mask = F.pad(mask, pad, mode="constant", value=0)
          kernel.append(mask)
      kernel = paddle.stack(kernel)
      results.append(kernel)
  
      return results
  
file_path: PaddleOCR/ppocr/losses/det_drrg_loss.py
imports: import paddle
  import paddle.nn.functional
  from paddle import nn
label_desc: Use image node_id 4 for calling the DRRGLoss obj's underlying member method code with example usage: obj.bitmasks2tensor(bitmasks, target_sz) and returns: results