code: def op_with_scalar_cast(a, b, f):
      """
      Builds the graph to compute f(a, b).
      If only one of the two arguments is a scalar and the operation would
      cause a type error without casting, casts the scalar to match the
      tensor.
      :param a: a tf-compatible array or scalar
      :param b: a tf-compatible array or scalar
      """
  
      try:
          return f(a, b)
      except (TypeError, ValueError):
          pass
  
      def is_scalar(x):
          """Return True if `x` is a scalar"""
          if hasattr(x, "get_shape"):
              shape = x.get_shape()
              return shape.ndims == 0
          if hasattr(x, "ndim"):
              return x.ndim == 0
          assert isinstance(x, (int, float))
          return True
  
      a_scalar = is_scalar(a)
      b_scalar = is_scalar(b)
  
      if a_scalar and b_scalar:
          raise TypeError(
              "Trying to apply " + str(f) + " with mixed types"
          )
  
      if a_scalar and not b_scalar:
          a = tf.cast(a, b.dtype)
  
      if b_scalar and not a_scalar:
          b = tf.cast(b, a.dtype)
  
      return f(a, b)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import logging
  import math
  import os
  import time
  import warnings
  import numpy
  import six
  from six.moves import xrange
  import tensorflow
  from cleverhans.compat import device_lib
  from cleverhans.compat import reduce_sum, reduce_mean
  from cleverhans.compat import reduce_max
  from cleverhans.compat import softmax_cross_entropy_with_logits
  from cleverhans.utils import batch_indices, _ArgsWrapper, create_logger
label_desc: Use image node_id 22 for calling a global function with example usage: op_with_scalar_cast(a, b, f) and returns: f, f, True, unknown, unknown