pypots/nn/modules/reformer/lsh_attention.py
File lsh_attention.py
has 471 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
"""
Locality-Sensitive Hashing (LSH) Attention from https://github.com/lucidrains/reformer-pytorch
"""
# Created by Wenjie Du <wenjay.du@gmail.com>
Function __init__
has 19 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function forward
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def forward(
self,
qk,
v,
query_len=None,
Function forward
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def forward(
self,
qk,
v,
query_len=None,
- 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 cache_method_decorator
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def cache_method_decorator(cache_attr, cache_namespace, reexecute=False):
def inner_fn(fn):
@wraps(fn)
def wrapper(self, *args, key_namespace=None, fetch=False, set_cache=True, **kwargs):
namespace_str = str(default(key_namespace, ""))
- 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 __init__
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(
Function forward
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def forward(
Function forward
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def forward(
Function forward
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def forward(self, qk, v, query_len=None, input_mask=None, input_attn_mask=None, **kwargs):
Function wrapper
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def wrapper(self, *args, key_namespace=None, fetch=False, set_cache=True, **kwargs):