tensorflow/models

View on GitHub
official/legacy/xlnet/xlnet_modeling.py

Summary

Maintainability
F
1 wk
Test Coverage

File xlnet_modeling.py has 1049 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/legacy/xlnet/xlnet_modeling.py - About 2 days to fix

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

      def call(self, inputs):
        """Implements call() for the layer."""
        inp_k = inputs["inp_k"]
        seg_id = inputs["seg_id"]
        input_mask = inputs["input_mask"]
    Severity: Minor
    Found in official/legacy/xlnet/xlnet_modeling.py - About 1 day 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 21 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def __init__(self,
    Severity: Major
    Found in official/legacy/xlnet/xlnet_modeling.py - About 2 hrs to fix

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

        def call(self, h, g, r, r_w_bias, r_r_bias, seg_mat, r_s_bias, seg_embed,
      Severity: Major
      Found in official/legacy/xlnet/xlnet_modeling.py - About 1 hr to fix

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

          def call(self, q_head, k_head_h, v_head_h, k_head_r, seg_embed, seg_mat,
        Severity: Major
        Found in official/legacy/xlnet/xlnet_modeling.py - About 1 hr to fix

          Function call has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def call(self, inputs):
              """Implements call() for the layer."""
              inp_k = inputs["inp_k"]
              seg_id = inputs["seg_id"]
              input_mask = inputs["input_mask"]
          Severity: Minor
          Found in official/legacy/xlnet/xlnet_modeling.py - About 1 hr to fix

            Function call has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def call(self, inputs, training=False):
                """Implements call() for the layer."""
                hidden, p_mask, cls_index, kwargs = inputs
                return_dict = {}
                seq_len = tf.shape(hidden)[1]
            Severity: Minor
            Found in official/legacy/xlnet/xlnet_modeling.py - About 1 hr to fix

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

                def __init__(self,
              Severity: Major
              Found in official/legacy/xlnet/xlnet_modeling.py - About 1 hr to fix

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

                  def __init__(self,
                Severity: Major
                Found in official/legacy/xlnet/xlnet_modeling.py - About 1 hr to fix

                  Function __call__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def __call__(self,
                  Severity: Major
                  Found in official/legacy/xlnet/xlnet_modeling.py - About 1 hr to fix

                    Function _cache_mem has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def _cache_mem(curr_out, prev_mem, mem_len, reuse_len=None):
                      """cache hidden states into memory."""
                    
                      if mem_len is None or mem_len == 0:
                        return None
                    Severity: Minor
                    Found in official/legacy/xlnet/xlnet_modeling.py - About 55 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

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

                      def __init__(self, d_model, n_head, d_head, dropout, dropout_att,
                    Severity: Major
                    Found in official/legacy/xlnet/xlnet_modeling.py - About 50 mins to fix

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

                        def __init__(self, d_model, d_inner, dropout, kernel_initializer,
                      Severity: Minor
                      Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

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

                          def __init__(self, xlnet_config, run_config, n_class, summary_type,
                        Severity: Minor
                        Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

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

                            def __init__(self, hidden_size, start_n_top, end_n_top, initializer,
                          Severity: Minor
                          Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

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

                              def __init__(self, xlnet_config, run_config, start_n_top, end_n_top,
                            Severity: Minor
                            Found in official/legacy/xlnet/xlnet_modeling.py - About 45 mins to fix

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

                                def __init__(self, use_proj, xlnet_config, run_config, use_legacy_mask=True,
                              Severity: Minor
                              Found in official/legacy/xlnet/xlnet_modeling.py - About 35 mins to fix

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

                                  def call(self, h, g, r, r_w_bias, r_r_bias, seg_mat, r_s_bias, seg_embed,
                                           attn_mask_h, attn_mask_g, mems, target_mapping):
                                    """Implements call() for the layer."""
                                
                                    if mems is not None and mems.shape.ndims > 1:
                                Severity: Minor
                                Found in official/legacy/xlnet/xlnet_modeling.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

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

                                      if dtype is not None and dtype != tf.float32:
                                        fwd_pos_seq = tf.cast(fwd_pos_seq, dtype=dtype)
                                        bwd_pos_seq = tf.cast(bwd_pos_seq, dtype=dtype)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 2 hrs to fix
                                official/nlp/modeling/networks/xlnet_base.py on lines 324..327

                                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 53.

                                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

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

                                  x = tf.reshape(x, [x_size[0], x_size[1] - 1, x_size[2], x_size[3]])
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 1 hr to fix
                                official/nlp/modeling/layers/relative_attention.py on lines 64..64

                                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 47.

                                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 mems is not None and mems.shape.ndims > 1:
                                      cat = tf.concat([mems, h], 0)
                                    else:
                                      cat = h
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 1 hr to fix
                                official/nlp/modeling/layers/relative_attention.py on lines 433..436

                                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

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

                                  x = tf.reshape(x, [x_size[1], x_size[0], x_size[2], x_size[3]])
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 1 hr to fix
                                official/nlp/modeling/layers/relative_attention.py on lines 62..62

                                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 41.

                                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 3 locations. Consider refactoring.
                                Open

                                      if dtype is not None and dtype != tf.float32:
                                        fwd_pos_seq = tf.cast(fwd_pos_seq, dtype=dtype)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 1 hr to fix
                                official/nlp/modeling/networks/xlnet_base.py on lines 310..311
                                official/nlp/modeling/networks/xlnet_base.py on lines 355..356

                                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 38.

                                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

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

                                    self._inv_freq = 1.0 / (10000.0**(
                                        tf.range(0, self._hidden_size, 2.0) / self._hidden_size))
                                Severity: Minor
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 55 mins to fix
                                official/nlp/modeling/networks/xlnet_base.py on lines 389..390

                                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 37.

                                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 3 locations. Consider refactoring.
                                Open

                                      self.r_r_bias = (
                                          self.add_weight(
                                              "r_r_bias",
                                              shape=[self.n_layer, self.n_head, self.d_head],
                                              dtype=self.tf_float,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 55 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 459..464
                                official/legacy/xlnet/xlnet_modeling.py on lines 471..476

                                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 37.

                                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 3 locations. Consider refactoring.
                                Open

                                      self.r_w_bias = (
                                          self.add_weight(
                                              "r_w_bias",
                                              shape=[self.n_layer, self.n_head, self.d_head],
                                              dtype=self.tf_float,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 55 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 465..470
                                official/legacy/xlnet/xlnet_modeling.py on lines 471..476

                                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 37.

                                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 3 locations. Consider refactoring.
                                Open

                                      self.r_s_bias = (
                                          self.add_weight(
                                              "r_s_bias",
                                              shape=[self.n_layer, self.n_head, self.d_head],
                                              dtype=self.tf_float,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 55 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 459..464
                                official/legacy/xlnet/xlnet_modeling.py on lines 465..470

                                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 37.

                                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 3 locations. Consider refactoring.
                                Open

                                    if self._use_legacy_mask:
                                      # Legacy input mask assumes `real` values are 0 and `padding`
                                      # values are 1.
                                      input_mask = 1 - features["input_mask"]
                                    else:
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 45 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 796..801
                                official/legacy/xlnet/xlnet_modeling.py on lines 1135..1140

                                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 35.

                                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 3 locations. Consider refactoring.
                                Open

                                    if self._use_legacy_mask:
                                      # Legacy input mask assumes `real` values are 0 and `padding`
                                      # values are 1.
                                      perm_mask = 1 - features["perm_mask"]
                                    else:
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 45 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 888..893
                                official/legacy/xlnet/xlnet_modeling.py on lines 1135..1140

                                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 35.

                                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 3 locations. Consider refactoring.
                                Open

                                    if self._use_legacy_mask:
                                      # Legacy input mask assumes `real` values are 0 and `padding`
                                      # values are 1.
                                      input_mask = 1 - features["input_mask"]
                                    else:
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 45 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 796..801
                                official/legacy/xlnet/xlnet_modeling.py on lines 888..893

                                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 35.

                                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 3 locations. Consider refactoring.
                                Open

                                      self.r_w_bias = (
                                          self.add_weight(
                                              "r_w_bias",
                                              shape=[self.n_head, self.d_head],
                                              dtype=self.tf_float,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 40 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 248..252
                                official/legacy/xlnet/xlnet_modeling.py on lines 484..489

                                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 34.

                                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 3 locations. Consider refactoring.
                                Open

                                    self.end_logits_proj_layer0 = tf_keras.layers.Dense(
                                        units=self.hidden_size,
                                        kernel_initializer=self.initializer,
                                        activation=tf.nn.tanh,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 40 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 1026..1030
                                official/legacy/xlnet/xlnet_modeling.py on lines 1199..1202

                                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 34.

                                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 3 locations. Consider refactoring.
                                Open

                                    if self.use_proj:
                                      self.proj_layer = tf_keras.layers.Dense(
                                          units=self.hidden_size,
                                          kernel_initializer=self.initializer,
                                          activation=tf.nn.tanh,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 40 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 1190..1193
                                official/legacy/xlnet/xlnet_modeling.py on lines 1199..1202

                                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 34.

                                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 3 locations. Consider refactoring.
                                Open

                                    self.answer_class_proj_layer0 = tf_keras.layers.Dense(
                                        units=self.hidden_size,
                                        kernel_initializer=self.initializer,
                                        activation=tf.nn.tanh,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 40 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 1026..1030
                                official/legacy/xlnet/xlnet_modeling.py on lines 1190..1193

                                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 34.

                                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 3 locations. Consider refactoring.
                                Open

                                    self.lookup_table = self.add_weight(
                                        "lookup_table",
                                        shape=[self.n_token, self.d_embed],
                                        initializer=self.initializer,
                                        dtype=self.dtype)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 40 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 478..483
                                official/legacy/xlnet/xlnet_modeling.py on lines 484..489

                                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 34.

                                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 3 locations. Consider refactoring.
                                Open

                                      self.r_r_bias = (
                                          self.add_weight(
                                              "r_r_bias",
                                              shape=[self.n_head, self.d_head],
                                              dtype=self.tf_float,
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 2 other locations - About 40 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 248..252
                                official/legacy/xlnet/xlnet_modeling.py on lines 478..483

                                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 34.

                                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 self.activation_type == "relu":
                                      activation = tf.nn.relu
                                    elif self.activation_type == "gelu":
                                      activation = gelu
                                    else:
                                Severity: Minor
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 35 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 576..583

                                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 33.

                                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 self.clamp_len > 0:
                                        fwd_pos_seq = tf.clip_by_value(fwd_pos_seq, -self.clamp_len,
                                                                       self.lamp_len)
                                Severity: Minor
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 35 mins to fix
                                research/efficient-hrl/agents/ddpg_agent.py on lines 365..366

                                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 33.

                                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 self.attn_type == "uni":
                                      attn_mask = _create_mask(qlen, mlen, self.tf_float, self.same_length)
                                      # pylint: enable=protected-access
                                      attn_mask = attn_mask[:, :, None, None]
                                    elif self.attn_type == "bi":
                                Severity: Minor
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 35 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 202..208

                                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 33.

                                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 5 locations. Consider refactoring.
                                Open

                                    self.kh_projection_layer = self.add_weight(
                                        "k/kernel",
                                        shape=[self.d_model, self.n_head, self.d_head],
                                        initializer=self.initializer)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 4 other locations - About 30 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 284..287
                                official/legacy/xlnet/xlnet_modeling.py on lines 288..291
                                official/legacy/xlnet/xlnet_modeling.py on lines 292..295
                                official/legacy/xlnet/xlnet_modeling.py on lines 300..303

                                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 32.

                                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 5 locations. Consider refactoring.
                                Open

                                    self.vh_projection_layer = self.add_weight(
                                        "v/kernel",
                                        shape=[self.d_model, self.n_head, self.d_head],
                                        initializer=self.initializer)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 4 other locations - About 30 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 280..283
                                official/legacy/xlnet/xlnet_modeling.py on lines 288..291
                                official/legacy/xlnet/xlnet_modeling.py on lines 292..295
                                official/legacy/xlnet/xlnet_modeling.py on lines 300..303

                                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 32.

                                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 5 locations. Consider refactoring.
                                Open

                                    self.kr_projection_layer = self.add_weight(
                                        "r/kernel",
                                        shape=[self.d_model, self.n_head, self.d_head],
                                        initializer=self.initializer)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 4 other locations - About 30 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 280..283
                                official/legacy/xlnet/xlnet_modeling.py on lines 284..287
                                official/legacy/xlnet/xlnet_modeling.py on lines 292..295
                                official/legacy/xlnet/xlnet_modeling.py on lines 300..303

                                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 32.

                                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 5 locations. Consider refactoring.
                                Open

                                    self.qh_projection_layer = self.add_weight(
                                        "q/kernel",
                                        shape=[self.d_model, self.n_head, self.d_head],
                                        initializer=self.initializer)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 4 other locations - About 30 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 280..283
                                official/legacy/xlnet/xlnet_modeling.py on lines 284..287
                                official/legacy/xlnet/xlnet_modeling.py on lines 288..291
                                official/legacy/xlnet/xlnet_modeling.py on lines 300..303

                                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 32.

                                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 5 locations. Consider refactoring.
                                Open

                                    self.proj_o = self.add_weight(
                                        "o/kernel",
                                        shape=[self.d_model, self.n_head, self.d_head],
                                        initializer=self.initializer)
                                Severity: Major
                                Found in official/legacy/xlnet/xlnet_modeling.py and 4 other locations - About 30 mins to fix
                                official/legacy/xlnet/xlnet_modeling.py on lines 280..283
                                official/legacy/xlnet/xlnet_modeling.py on lines 284..287
                                official/legacy/xlnet/xlnet_modeling.py on lines 288..291
                                official/legacy/xlnet/xlnet_modeling.py on lines 292..295

                                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 32.

                                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 input_mask is not None and perm_mask is None:
                                      data_mask = input_mask[None]
                                    elif input_mask is None and perm_mask is not None:
                                      data_mask = perm_mask
                                    else:
                                Severity: Minor
                                Found in official/legacy/xlnet/xlnet_modeling.py and 1 other location - About 30 mins to fix
                                official/nlp/modeling/networks/xlnet_base.py on lines 172..177

                                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 32.

                                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