(variable_name, only_if=lambda x: True)
return (only_if(variable_name) and is_embedding_var and
          not is_head_classifier_var and not is_relationnet_var and
          not is_optimizer_var)
Returns True if `variable_name` refers to a backbone variable.

  Args:
    variable_name: A string; the name of a `tf.Variable` that will be checked to
      determine whether the variable belongs to the backbone (embedding
      function) of a `Learner`.
    only_if: A callable that returns `True` when the name of a `tf.Variable`
      satisfies some condition; by default `only_if` returns `True` for any
      argument.

  Returns:
    `True` if the `tf.Variable` to which `variable_name` refers belongs to a
    backbone (embedding function) and `only_if(variable_name)` is also
    satisfied.
Returns True if `variable_name` refers to a backbone variable.
Returns True if variable_name refers to a backbone variable .
def is_backbone_variable(variable_name, only_if=lambda x: True):
  """Returns True if `variable_name` refers to a backbone variable.

  Args:
    variable_name: A string; the name of a `tf.Variable` that will be checked to
      determine whether the variable belongs to the backbone (embedding
      function) of a `Learner`.
    only_if: A callable that returns `True` when the name of a `tf.Variable`
      satisfies some condition; by default `only_if` returns `True` for any
      argument.

  Returns:
    `True` if the `tf.Variable` to which `variable_name` refers belongs to a
    backbone (embedding function) and `only_if(variable_name)` is also
    satisfied.
  """
  variable_name = variable_name.lower()

  # We restore all embedding variables.
  is_embedding_var = any(
      keyword in variable_name for keyword in EMBEDDING_KEYWORDS)

  # We exclude all head classifier variables.
  is_head_classifier_var = any(
      keyword in variable_name for keyword in HEAD_CLASSIFIER_KEYWORDS)

  # We exclude 'relation*' variables as they are not present in a pretrained
  # checkpoint.
  is_relationnet_var = variable_name.startswith('relation')

  # We exclude optimizer variables, as the episodic finetuning procedure is a
  # different optimization problem than the original training objective.
  is_optimizer_var = any(
      keyword in variable_name for keyword in OPTIMIZER_KEYWORDS)

  return (only_if(variable_name) and is_embedding_var and
          not is_head_classifier_var and not is_relationnet_var and
          not is_optimizer_var)
def is_backbone_variable ( variable_name , only_if = lambda x : True ) : variable_name = variable_name . lower ( ) # We restore all embedding variables. is_embedding_var = any ( keyword in variable_name for keyword in EMBEDDING_KEYWORDS ) # We exclude all head classifier variables. is_head_classifier_var = any ( keyword in variable_name for keyword in HEAD_CLASSIFIER_KEYWORDS ) # We exclude 'relation*' variables as they are not present in a pretrained # checkpoint. is_relationnet_var = variable_name . startswith ( 'relation' ) # We exclude optimizer variables, as the episodic finetuning procedure is a # different optimization problem than the original training objective. is_optimizer_var = any ( keyword in variable_name for keyword in OPTIMIZER_KEYWORDS ) return ( only_if ( variable_name ) and is_embedding_var and not is_head_classifier_var and not is_relationnet_var and not is_optimizer_var )