class_docstr: Implements MASTER as described in paper: <https://arxiv.org/pdf/1910.02562.pdf>`_.
  Implementation based on the official TF implementation: <https://github.com/jiangxiluning/MASTER-TF>`_.
  
  Args:
  ----
      feature_extractor: the backbone serving as feature extractor
      vocab: vocabulary, (without EOS, SOS, PAD)
      d_model: d parameter for the transformer decoder
      dff: depth of the pointwise feed-forward layer
      num_heads: number of heads for the mutli-head attention module
      num_layers: number of decoder layers to stack
      max_length: maximum length of character sequence handled by the model
      dropout: dropout probability of the decoder
      input_shape: size of the image inputs
      exportable: onnx exportable returns only logits
      cfg: dictionary containing information about the model
class_docstr_tok: ["Implements","MASTER","as","described","in","paper",":","<","https",":","\/\/arxiv.org\/pdf\/1910.02562.pdf",">","`","_",".","Implementation","based","on","the","official","TF","implementation",":","<","https",":","\/\/github.com\/jiangxiluning\/MASTER-TF",">","`","_",".","Args",":","--","--","feature_extractor",":","the","backbone","serving","as","feature","extractor","vocab",":","vocabulary",",","(","without","EOS",",","SOS",",","PAD",")","d_model",":","d","parameter","for","the","transformer","decoder","dff",":","depth","of","the","pointwise","feed-forward","layer","num_heads",":","number","of","heads","for","the","mutli-head","attention","module","num_layers",":","number","of","decoder","layers","to","stack","max_length",":","maximum","length","of","character","sequence","handled","by","the","model","dropout",":","dropout","probability","of","the","decoder","input_shape",":","size","of","the","image","inputs","exportable",":","onnx","exportable","returns","only","logits","cfg",":","dictionary","containing","information","about","the","model"]
code: def make_source_and_target_mask(
      self, source: tf.Tensor, target: tf.Tensor
  ) -> Tuple[tf.Tensor, tf.Tensor]:
      # [1, 1, 1, ..., 0, 0, 0] -> 0 is masked
      # (N, 1, 1, max_length)
      target_pad_mask = tf.cast(
          tf.math.not_equal(target, self.vocab_size + 2), dtype=tf.uint8
      )
      target_pad_mask = target_pad_mask[:, tf.newaxis, tf.newaxis, :]
      target_length = target.shape[1]
      # sub mask filled diagonal with 1 = see 0 = masked (max_length, max_length)
      target_sub_mask = tf.linalg.band_part(
          tf.ones((target_length, target_length)), -1, 0
      )
      # source mask filled with ones (max_length, positional_encoded_seq_len)
      source_mask = tf.ones((target_length, source.shape[1]))
      # combine the two masks into one boolean mask where False is masked (N, 1, max_length, max_length)
      target_mask = tf.math.logical_and(
          tf.cast(target_sub_mask, dtype=tf.bool),
          tf.cast(target_pad_mask, dtype=tf.bool),
      )
      return source_mask, target_mask
  
imports: from copy import deepcopy
  from typing import Any, Dict, List, Optional, Tuple
  import tensorflow
  from tensorflow.keras import Model, layers
  from doctr.datasets import VOCABS
  from doctr.models.classification import magc_resnet31
  from doctr.models.modules.transformer import Decoder, PositionalEncoding
  from ...utils.tensorflow import _bf16_to_float32, load_pretrained_params
  from .base import _MASTER, _MASTERPostProcessor
label_desc: Use image node_id 2 for calling the MASTER obj's underlying member method code with example usage: obj.make_source_and_target_mask(source, target) and returns: source_mask,  target_mask