official/nlp/modeling/layers/block_sparse_attention.py
Function _build_from_signature
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
Open
def _build_from_signature(self, query, value, key=None):
# pytype: disable=attribute-error
super()._build_from_signature(query, value, key)
# pytype: enable=attribute-error
# If block sizes are same as sequence lengths, we defer to default attn.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function call
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def call(
Function _compute_attention
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def _compute_attention(
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function _compute_attention
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def _compute_attention(
self, query, key, value, attention_mask=None, training=None
):
# If block sizes are same as sequence lengths, we defer to default attn.
if (
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"