official/nlp/finetuning/binary_helper.py
File binary_helper.py
has 385 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
Function override_qa_task_config
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def override_qa_task_config(
Function override_sentence_prediction_task_config
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def override_sentence_prediction_task_config(
Function override_trainer_cfg
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def override_trainer_cfg(trainer_cfg: cfg.TrainerConfig, learning_rate: float,
Function write_glue_classification
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def write_glue_classification(task,
Function write_question_answering
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def write_question_answering(task,
Function write_xtreme_classification
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def write_xtreme_classification(task,
Function override_tagging_task_config
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def override_tagging_task_config(task_cfg: tagging.TaggingConfig,
Function write_glue_classification
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def write_glue_classification(task,
model,
input_file,
output_file,
predict_batch_size,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function write_superglue_classification
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def write_superglue_classification(task,
Function load_model_config_file
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
def load_model_config_file(model_config_file: str) -> Dict[str, Any]:
"""Loads bert config json file or `encoders.EncoderConfig` in yaml file."""
if not model_config_file:
# model_config_file may be empty when using tf.hub.
return {}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function write_tagging
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def write_tagging(task, model, input_file, output_file, predict_batch_size,