tensorflow/models

View on GitHub
official/nlp/modeling/networks/funnel_transformer.py

Summary

Maintainability
D
2 days
Test Coverage

File funnel_transformer.py has 509 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2024 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in official/nlp/modeling/networks/funnel_transformer.py - About 1 day to fix

    Function call has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

      def call(self, inputs, output_range: Optional[tf.Tensor] = None):
        # inputs are [word_ids, mask, type_ids]
        word_embeddings = None
        if isinstance(inputs, (list, tuple)):
          logging.warning('List inputs to  %s are discouraged.', self.__class__)
    Severity: Minor
    Found in official/nlp/modeling/networks/funnel_transformer.py - About 5 hrs to fix

    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 a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def __init__(
          self,
          vocab_size: int,
          hidden_size: int = 768,
          num_layers: int = 12,
    Severity: Minor
    Found in official/nlp/modeling/networks/funnel_transformer.py - About 3 hrs to fix

    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 22 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(
    Severity: Major
    Found in official/nlp/modeling/networks/funnel_transformer.py - About 2 hrs to fix

      Function _create_truncated_avg_transforms has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def _create_truncated_avg_transforms(
          seq_length: int, pool_strides: Sequence[int]
      ):
        """Computes pooling transforms.
      
      
      Severity: Minor
      Found in official/nlp/modeling/networks/funnel_transformer.py - About 1 hr to fix

      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 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def __init__(
            self,
            vocab_size: int,
            hidden_size: int = 768,
            num_layers: int = 12,
      Severity: Minor
      Found in official/nlp/modeling/networks/funnel_transformer.py - About 1 hr to fix

        Function _pool_and_concat has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def _pool_and_concat(mask, unpool_length: int, strides: Union[Sequence[int],
                                                                      int],
                             axes: Union[Sequence[int], int]):
          """Pools the mask along a given axis with stride.
        
        
        Severity: Minor
        Found in official/nlp/modeling/networks/funnel_transformer.py - About 35 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status