File rasa_layers.py
has 868 lines of code (exceeds 250 allowed). Consider refactoring. Open
import tensorflow as tf
import numpy as np
from typing import Text, List, Dict, Any, Union, Optional, Tuple, Callable
from rasa.shared.nlu.constants import TEXT
Function adjust_sparse_layers_for_incremental_training
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def adjust_sparse_layers_for_incremental_training(
self,
new_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
old_sparse_feature_sizes: Dict[Text, Dict[Text, List[int]]],
reg_lambda: float,
- 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 prepare_transformer_layer
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def prepare_transformer_layer(
Function _create_mlm_tensors
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _create_mlm_tensors(
Function _replace_dense_for_sparse_layer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _replace_dense_for_sparse_layer(
Function _calculate_output_units
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _calculate_output_units(
Function _prepare_sequence_sentence_concat
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _prepare_sequence_sentence_concat(
self, attribute: Text, config: Dict[Text, Any]
) -> None:
"""Sets up combining sentence- and sequence-level features (if needed).
- 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 _features_as_token_ids
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _features_as_token_ids(
self, features: List[Union[tf.Tensor, tf.SparseTensor]]
) -> Optional[tf.Tensor]:
"""Creates dense labels (token IDs) used for negative sampling in MLM."""
# If there are dense features, we use them as labels - taking the first dense
- 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"