class_docstr: SPTS Decoder.
  
  Args:
      dictionary (dict or :obj:`Dictionary`): The config for `Dictionary` or
          the instance of `Dictionary`.
      num_bins (int): Number of bins dividing the image. Defaults to 1000.
      n_head (int): Number of parallel attention heads. Defaults to 8.
      d_model (int): Dimension :math:`D_m` of the input from previous model.
          Defaults to 256.
      d_feedforward (int): Dimension of the feedforward layer.
          Defaults to 1024.
      normalize_before (bool): Whether to normalize the input before
          encoding/decoding. Defaults to True.
      max_num_text (int): Maximum number of text instances in a sample.
          Defaults to 60.
      module_loss (dict, optional): Config to build loss. Defaults to None.
      postprocessor (dict, optional): Config to build postprocessor.
          Defaults to None.
      init_cfg (dict or list[dict], optional): Initialization configs.
          Defaults to None.
class_docstr_tok: ["SPTS","Decoder",".","Args",":","dictionary","(","dict","or",":","obj",":","`","Dictionary","`",")",":","The","config","for","`","Dictionary","`","or","the","instance","of","`","Dictionary","`",".","num_bins","(","int",")",":","Number","of","bins","dividing","the","image",".","Defaults","to","1000.","n_head","(","int",")",":","Number","of","parallel","attention","heads",".","Defaults","to","8.","d_model","(","int",")",":","Dimension",":","math",":","`","D_m","`","of","the","input","from","previous","model",".","Defaults","to","256.","d_feedforward","(","int",")",":","Dimension","of","the","feedforward","layer",".","Defaults","to","1024.","normalize_before","(","bool",")",":","Whether","to","normalize","the","input","before","encoding\/decoding",".","Defaults","to","True",".","max_num_text","(","int",")",":","Maximum","number","of","text","instances","in","a","sample",".","Defaults","to","60.","module_loss","(","dict",",","optional",")",":","Config","to","build","loss",".","Defaults","to","None",".","postprocessor","(","dict",",","optional",")",":","Config","to","build","postprocessor",".","Defaults","to","None",".","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","configs",".","Defaults","to","None","."]
code: def _embed(self, out_enc, data_samples):
      bs, c, h, w = out_enc.shape
      mask, pos_embed = self._gen_mask(out_enc, data_samples)
      out_enc = out_enc.flatten(2).permute(2, 0, 1)
      pos_embed = pos_embed.flatten(2).permute(2, 0, 1)
      mask = mask.flatten(1)
      # TODO move encoder to mmcv
      memory = self.encoder(
          out_enc, src_key_padding_mask=mask, pos=pos_embed.half()
      )
  
      query_embed = self.embedding.position_embeddings.weight.unsqueeze(
          1
      )
      query_embed = query_embed.repeat(1, bs, 1)
      return mask, pos_embed, memory, query_embed
  
imports: import copy
  from typing import Dict, List, Optional, Sequence, Union
  import torch
  import torch.nn.functional
  from torch import Tensor, nn
  from mmocr.models.common import Dictionary
  from mmocr.models.textrecog.decoders import BaseDecoder
  from mmocr.registry import MODELS
  from mmocr.utils.typing_utils import TextSpottingDataSample
  from .position_embedding import PositionEmbeddingSine
label_desc: Use image node_id 6 for calling the SPTSDecoder obj's underlying member method code with example usage: obj._embed(out_enc, data_samples) and returns: mask,  pos_embed,  memory,  query_embed