tensorflow/models

View on GitHub
official/nlp/modeling/layers/bigbird_attention.py

Summary

Maintainability
F
6 days
Test Coverage

File bigbird_attention.py has 415 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: Minor
Found in official/nlp/modeling/layers/bigbird_attention.py - About 5 hrs to fix

    Function bigbird_block_sparse_attention has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def bigbird_block_sparse_attention(
        query_layer, key_layer, value_layer, band_mask, from_mask, to_mask,
        from_blocked_mask, to_blocked_mask, rand_attn, num_attention_heads,
        num_rand_blocks, size_per_head, batch_size, from_seq_length, to_seq_length,
        from_block_size, to_block_size):
    Severity: Major
    Found in official/nlp/modeling/layers/bigbird_attention.py - About 3 hrs to fix

      Function bigbird_block_sparse_attention has 17 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def bigbird_block_sparse_attention(
      Severity: Major
      Found in official/nlp/modeling/layers/bigbird_attention.py - About 2 hrs to fix

        Function bigbird_block_rand_mask has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def bigbird_block_rand_mask(from_seq_length,
                                    to_seq_length,
                                    from_block_size,
                                    to_block_size,
                                    num_rand_blocks,
        Severity: Minor
        Found in official/nlp/modeling/layers/bigbird_attention.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 create_rand_mask_from_inputs has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def create_rand_mask_from_inputs(from_blocked_mask, to_blocked_mask, rand_attn,
        Severity: Major
        Found in official/nlp/modeling/layers/bigbird_attention.py - About 1 hr to fix

          Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def __init__(self,
          Severity: Minor
          Found in official/nlp/modeling/layers/bigbird_attention.py - About 45 mins to fix

            Function bigbird_block_rand_mask has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def bigbird_block_rand_mask(from_seq_length,
            Severity: Minor
            Found in official/nlp/modeling/layers/bigbird_attention.py - About 45 mins to fix

              Function call has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def call(self, query, value, key=None, attention_mask=None, **kwargs):  # pytype: disable=signature-mismatch  # overriding-parameter-count-checks
              Severity: Minor
              Found in official/nlp/modeling/layers/bigbird_attention.py - About 35 mins to fix

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                  second_last_value_mat = tf.concat([
                      blocked_value_matrix[:, :, 0], blocked_value_matrix[:, :, -3],
                      blocked_value_matrix[:, :, -2], blocked_value_matrix[:, :, -1],
                      gathered_value[:, :, -1]
                  ], 2)  # [b, h, (4+r)*wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 3 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 235..239
                official/nlp/modeling/layers/bigbird_attention.py on lines 240..244
                official/nlp/modeling/layers/bigbird_attention.py on lines 322..326

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                  second_key_mat = tf.concat([
                      blocked_key_matrix[:, :, 0], blocked_key_matrix[:, :, 1],
                      blocked_key_matrix[:, :, 2], blocked_key_matrix[:, :,
                                                                      -1], gathered_key[:, :, 0]
                  ], 2)  # [b, h, (4+r)*wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 3 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 240..244
                official/nlp/modeling/layers/bigbird_attention.py on lines 322..326
                official/nlp/modeling/layers/bigbird_attention.py on lines 327..331

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                  second_value_mat = tf.concat([
                      blocked_value_matrix[:, :, 0], blocked_value_matrix[:, :, 1],
                      blocked_value_matrix[:, :, 2], blocked_value_matrix[:, :, -1],
                      gathered_value[:, :, 0]
                  ], 2)  # [b, h, (4+r)*wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 3 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 235..239
                official/nlp/modeling/layers/bigbird_attention.py on lines 322..326
                official/nlp/modeling/layers/bigbird_attention.py on lines 327..331

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                  second_last_key_mat = tf.concat([
                      blocked_key_matrix[:, :, 0], blocked_key_matrix[:, :, -3],
                      blocked_key_matrix[:, :, -2], blocked_key_matrix[:, :, -1],
                      gathered_key[:, :, -1]
                  ], 2)  # [b, h, (4+r)*wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 3 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 235..239
                official/nlp/modeling/layers/bigbird_attention.py on lines 240..244
                official/nlp/modeling/layers/bigbird_attention.py on lines 327..331

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 68.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  exp_blocked_value_matrix = tf.concat([
                      blocked_value_matrix[:, :, 1:-3], blocked_value_matrix[:, :, 2:-2],
                      blocked_value_matrix[:, :, 3:-1]
                  ], 3)  # [b, h, m//wm-4, 3*wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 2 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 264..267

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 52.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  exp_blocked_key_matrix = tf.concat([
                      blocked_key_matrix[:, :, 1:-3], blocked_key_matrix[:, :, 2:-2],
                      blocked_key_matrix[:, :, 3:-1]
                  ], 3)  # [b, h, m//wm-4, 3*wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 2 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 268..271

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 52.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  gathered_value = tf.reshape(
                      tf.gather(
                          blocked_value_matrix, rand_attn, batch_dims=2, name="gather_value"),
                      (b, h, m // wm - 2, r * wn, -1))  # [b, h, n//wn-2, r, wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 2 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 217..219

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 50.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  gathered_key = tf.reshape(
                      tf.gather(blocked_key_matrix, rand_attn, batch_dims=2, name="gather_key"),
                      (b, h, m // wm - 2, r * wn, -1))  # [b, h, n//wn-2, r, wn, -1]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 2 hrs to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 220..223

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 50.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  second_rand_pad = tf.concat([
                      tf.ones([b, h, wm, 4 * wn], dtype=dtype), rand_mask[:, :, 0]
                  ], 3)
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 339..340

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 46.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  second_last_rand_pad = tf.concat(
                      [tf.ones([b, h, wm, 4 * wn], dtype=dtype), rand_mask[:, :, -1]], 3)
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 252..254

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 46.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    if i == 1:
                      rand_attn[i - 1, :] = np.random.permutation(middle_seq[2:last])[:r]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 82..83

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 42.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    elif i == 2:
                      rand_attn[i - 1, :] = np.random.permutation(middle_seq[3:last])[:r]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 1 other location - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 80..81

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 42.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                    elif i == from_seq_length // from_block_size - 3:
                      rand_attn[i - 1, :] = np.random.permutation(middle_seq[:last])[:r]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 87..88
                official/nlp/modeling/layers/bigbird_attention.py on lines 93..93
                official/nlp/modeling/layers/bigbird_attention.py on lines 94..95

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 40.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                        rand_attn[i - 1, :] = np.random.permutation(middle_seq[:start])[:r]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 84..85
                official/nlp/modeling/layers/bigbird_attention.py on lines 87..88
                official/nlp/modeling/layers/bigbird_attention.py on lines 94..95

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 40.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                    elif i == from_seq_length // from_block_size - 2:
                      rand_attn[i - 1, :] = np.random.permutation(middle_seq[:last])[:r]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 84..85
                official/nlp/modeling/layers/bigbird_attention.py on lines 93..93
                official/nlp/modeling/layers/bigbird_attention.py on lines 94..95

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 40.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 4 locations. Consider refactoring.
                Open

                      elif (end + 1) == last:
                        rand_attn[i - 1, :] = np.random.permutation(middle_seq[:start])[:r]
                Severity: Major
                Found in official/nlp/modeling/layers/bigbird_attention.py and 3 other locations - About 1 hr to fix
                official/nlp/modeling/layers/bigbird_attention.py on lines 84..85
                official/nlp/modeling/layers/bigbird_attention.py on lines 87..88
                official/nlp/modeling/layers/bigbird_attention.py on lines 93..93

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 40.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status