tensorflow/models

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

Summary

Maintainability
F
1 wk
Test Coverage

File data_utils.py has 562 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/data_utils.py - About 1 day to fix

    Function create_pretrain_dataset has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def create_pretrain_dataset(file_names,
                                bsz_per_core,
                                seq_len,
                                reuse_len,
                                perm_size,
    Severity: Minor
    Found in official/legacy/xlnet/data_utils.py - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function file_based_input_fn_builder has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def file_based_input_fn_builder(input_file, name_to_features, batch_size,
                                    is_training):
      """Creates an `input_fn` closure."""
    
      logging.info("Input tfrecord file %s", input_file)
    Severity: Minor
    Found in official/legacy/xlnet/data_utils.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

    def get_pretrain_input_data(batch_size,
                                seq_len,
                                strategy,
                                file_path,
                                reuse_len,
    Severity: Minor
    Found in official/legacy/xlnet/data_utils.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 get_pretrain_input_data has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_pretrain_input_data(batch_size,
    Severity: Major
    Found in official/legacy/xlnet/data_utils.py - About 1 hr to fix

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

      def create_pretrain_dataset(file_names,
      Severity: Major
      Found in official/legacy/xlnet/data_utils.py - About 1 hr to fix

        Function _word_span_mask has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def _word_span_mask(inputs, tgt_len, num_predict, min_num_words, max_num_words,
                            boundary):
          """Sample whole word spans as prediction targets."""
          # Note: 1.2 is the token-to-word ratio
          mask_alpha = tgt_len / num_predict / 1.2
        Severity: Minor
        Found in official/legacy/xlnet/data_utils.py - About 1 hr to fix

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

          def get_squad_input_data(batch_size, seq_len, q_len, strategy, is_training,
          Severity: Minor
          Found in official/legacy/xlnet/data_utils.py - About 45 mins to fix

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

            def _word_span_mask(inputs, tgt_len, num_predict, min_num_words, max_num_words,
            Severity: Minor
            Found in official/legacy/xlnet/data_utils.py - About 45 mins to fix

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

              def format_filename(prefix,
              Severity: Minor
              Found in official/legacy/xlnet/data_utils.py - About 45 mins to fix

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

                def get_classification_input_data(batch_size, seq_len, strategy, is_training,
                Severity: Minor
                Found in official/legacy/xlnet/data_utils.py - About 35 mins to fix

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

                  def parse_files_to_dataset(parser,
                  Severity: Minor
                  Found in official/legacy/xlnet/data_utils.py - About 35 mins to fix

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

                    def _token_span_mask(inputs, tgt_len, num_predict, min_num_tokens,
                    Severity: Minor
                    Found in official/legacy/xlnet/data_utils.py - About 35 mins to fix

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

                      def _local_perm(inputs, is_masked, perm_size, seq_len, leak_ratio):
                      Severity: Minor
                      Found in official/legacy/xlnet/data_utils.py - About 35 mins to fix

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

                        def _online_sample_masks(inputs,
                        Severity: Minor
                        Found in official/legacy/xlnet/data_utils.py - About 35 mins to fix

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

                          def _idx_pair_to_mask(beg_indices, end_indices, inputs, tgt_len, num_predict):
                          Severity: Minor
                          Found in official/legacy/xlnet/data_utils.py - About 35 mins to fix

                            Function get_squad_input_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def get_squad_input_data(batch_size, seq_len, q_len, strategy, is_training,
                                                     file_path):
                              """Returns input dataset from input file string."""
                            
                              # When using TPU pods, we need to clone dataset across
                            Severity: Minor
                            Found in official/legacy/xlnet/data_utils.py - About 25 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

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

                                if num_predict is not None:
                                  indices = tf.range(seq_len, dtype=tf.int64)
                                  bool_target_mask = tf.cast(target_mask, tf.bool)
                                  indices = tf.boolean_mask(indices, bool_target_mask)
                            
                            
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 3 days to fix
                            official/legacy/xlnet/preprocess_pretrain_data.py on lines 793..823

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

                            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

                              def _decode_record(record, name_to_features):
                                """Decodes a record to a TensorFlow example."""
                                example = tf.io.parse_single_example(record, name_to_features)
                            
                                # tf.Example only supports tf.int64, but the TPU only supports tf.int32.
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 2 other locations - About 5 hrs to fix
                            official/legacy/bert/input_pipeline.py on lines 20..32
                            official/projects/nhnet/input_pipeline.py on lines 20..32

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

                            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

                                if isinstance(input_file, str) or len(input_file) == 1:
                                  options = tf.data.Options()
                                  options.experimental_distribute.auto_shard_policy = (
                                      tf.data.experimental.AutoShardPolicy.OFF)
                                  d = d.with_options(options)
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 3 hrs to fix
                            official/legacy/bert/input_pipeline.py on lines 49..53

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

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

                              if use_dataset_fn:
                                if batch_size % strategy.num_replicas_in_sync != 0:
                                  raise ValueError(
                                      "Batch size must be divisible by number of replicas : {}".format(
                                          strategy.num_replicas_in_sync))
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 3 other locations - About 2 hrs to fix
                            official/legacy/xlnet/data_utils.py on lines 179..189
                            official/legacy/xlnet/data_utils.py on lines 614..624
                            official/projects/nhnet/input_pipeline.py on lines 222..232

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

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

                              if use_dataset_fn:
                                if batch_size % strategy.num_replicas_in_sync != 0:
                                  raise ValueError(
                                      "Batch size must be divisible by number of replicas : {}".format(
                                          strategy.num_replicas_in_sync))
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 3 other locations - About 2 hrs to fix
                            official/legacy/xlnet/data_utils.py on lines 179..189
                            official/legacy/xlnet/data_utils.py on lines 212..222
                            official/projects/nhnet/input_pipeline.py on lines 222..232

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

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

                              if use_dataset_fn:
                                if batch_size % strategy.num_replicas_in_sync != 0:
                                  raise ValueError(
                                      "Batch size must be divisible by number of replicas : {}".format(
                                          strategy.num_replicas_in_sync))
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 3 other locations - About 2 hrs to fix
                            official/legacy/xlnet/data_utils.py on lines 212..222
                            official/legacy/xlnet/data_utils.py on lines 614..624
                            official/projects/nhnet/input_pipeline.py on lines 222..232

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

                            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

                                for filename in cur_record_info["filenames"]:
                                  basename = os.path.basename(filename)
                                  new_filename = os.path.join(record_dir, basename)
                                  new_filenames.append(new_filename)
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 1 hr to fix
                            official/legacy/xlnet/preprocess_pretrain_data.py on lines 918..921

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

                            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

                              span_lens = tf.random.categorical(
                                  logits=logits[None],
                                  num_samples=num_predict,
                                  dtype=tf.int64,
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 1 hr to fix
                            official/legacy/xlnet/data_utils.py on lines 278..281

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

                              span_lens = tf.random.categorical(
                                  logits=logits[None],
                                  num_samples=num_predict,
                                  dtype=tf.int64,
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 1 hr to fix
                            official/legacy/xlnet/data_utils.py on lines 327..330

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

                              def _dataset_fn(ctx=None):
                                del ctx
                            
                                train_dataset = create_classification_dataset(
                                    file_path=file_path,
                            Severity: Minor
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 40 mins to fix
                            official/legacy/xlnet/data_utils.py on lines 233..241

                            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

                              def _dataset_fn(ctx=None):
                                del ctx
                            
                                train_dataset = create_squad_dataset(
                                    file_path=global_input_paths,
                            Severity: Minor
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 40 mins to fix
                            official/legacy/xlnet/data_utils.py on lines 191..199

                            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

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

                              if input_pipeline_context and input_pipeline_context.num_input_pipelines > 1:
                                dataset = dataset.shard(input_pipeline_context.num_input_pipelines,
                                                        input_pipeline_context.input_pipeline_id)
                            Severity: Major
                            Found in official/legacy/xlnet/data_utils.py and 4 other locations - About 35 mins to fix
                            official/legacy/bert/input_pipeline.py on lines 93..95
                            official/legacy/bert/input_pipeline.py on lines 173..175
                            official/legacy/bert/input_pipeline.py on lines 222..224
                            official/legacy/bert/input_pipeline.py on lines 267..269

                            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

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

                              non_func_tokens = tf.logical_not(
                                  tf.logical_or(tf.equal(inputs, SEP_ID), tf.equal(inputs, CLS_ID)))
                            Severity: Minor
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 30 mins to fix
                            official/legacy/xlnet/preprocess_pretrain_data.py on lines 688..690

                            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

                                d = d.map(
                                    lambda record: _decode_record(record, name_to_features),
                                    num_parallel_calls=tf.data.experimental.AUTOTUNE)
                            Severity: Minor
                            Found in official/legacy/xlnet/data_utils.py and 1 other location - About 30 mins to fix
                            official/legacy/bert/input_pipeline.py on lines 42..44

                            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