da39848ecdca190445b6786cb16f93fc921f3be8,keras/utils/control_flow_util.py,,smart_cond,#Any#Any#Any#Any#,89

Before Change


  if isinstance(pred, tf.Variable):
    return tf.compat.v1.cond(
        pred, true_fn=true_fn, false_fn=false_fn, name=name)
  return smart_module.smart_cond(
      pred, true_fn=true_fn, false_fn=false_fn, name=name)


def constant_value(pred):  // pylint: disable=invalid-name
  Return the bool value for `pred`, or None if `pred` had a dynamic value.

After Change



  if not callable(true_fn):
    raise TypeError("`true_fn` must be callable.")
  if not callable(false_fn):
    raise TypeError("`false_fn` must be callable.")

  pred_value = constant_value(pred)
  if pred_value is not None:
    if pred_value:
      return true_fn()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: keras-team/keras
Commit Name: da39848ecdca190445b6786cb16f93fc921f3be8
Time: 2021-02-22
Author: scottzhu@google.com
File Name: keras/utils/control_flow_util.py
Class Name:
Method Name: smart_cond


Project Name: allenai/allennlp
Commit Name: 28028a0544632307fe48e66a15a4b2a22c3dddda
Time: 2020-02-14
Author: dirkg@allenai.org
File Name: allennlp/common/from_params.py
Class Name:
Method Name: construct_arg


Project Name: PetrochukM/PyTorch-NLP
Commit Name: 6a5916968838686e332fb68a10cb30222843fbd9
Time: 2018-04-26
Author: florian.joh.schaefer@gmail.com
File Name: torchnlp/word_to_vector/pretrained_word_vectors.py
Class Name: _PretrainedWordVectors
Method Name: __getitem__