# tensorplay.nn.attention.create_mask Source: https://www.tensorplay.cn/docs/generated/tensorplay.nn.attention.create_mask.html ```python tensorplay.nn.attention.create_mask(mod_fn: _score_mod_signature | _mask_mod_signature, B: int | None, H: int | None, Q_LEN: int, KV_LEN: int, device: DeviceLikeType | None = None) → Tensor ``` This function creates a mask tensor from a mod_fn function. Parameters: - mod_fn (Union[_score_mod_signature, _mask_mod_signature]) – Function to modify attention scores. - B ([int](https://docs.python.org/3/builtins/functions.html#int)) – Batch size. - H ([int](https://docs.python.org/3/builtins/functions.html#int)) – Number of query heads. - Q_LEN ([int](https://docs.python.org/3/builtins/functions.html#int)) – Sequence length of query. - KV_LEN ([int](https://docs.python.org/3/builtins/functions.html#int)) – Sequence length of key/value. - device ([str](https://docs.python.org/3/builtins/stdtypes.html#str)) – Device to run the mask creation on. Returns: A mask tensor with shape (B, H, M, N). Return type: mask ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor))