original_docstring: Returns a function that can be executed in either graph or eager mode.
  
      The function must take only positional args.
  
      If eager is enabled, this will act as just a function. Otherwise, it
      will build a function that executes a session run with placeholders
      internally.
  
      Args:
          session_or_none (tf.Session): tf.Session if in graph mode, else None.
          dynamic_shape (bool): True if the placeholders should have a dynamic
              batch dimension. Otherwise they will be fixed shape.
  
      Returns:
          a Python function that can be called in either mode.
      
docstring: Returns a function that can be executed in either graph or eager mode.
  The function must take only positional args.
  
  If eager is enabled, this will act as just a function. Otherwise, it
  will build a function that executes a session run with placeholders
  internally.
docstring_tokens: Returns a function that can be executed in either graph or eager mode . The function must take only positional args . If eager is enabled this will act as just a function . Otherwise it will build a function that executes a session run with placeholders internally .
code: def make_tf_callable(session_or_none, dynamic_shape=False):
      """Returns a function that can be executed in either graph or eager mode.
  
      The function must take only positional args.
  
      If eager is enabled, this will act as just a function. Otherwise, it
      will build a function that executes a session run with placeholders
      internally.
  
      Args:
          session_or_none (tf.Session): tf.Session if in graph mode, else None.
          dynamic_shape (bool): True if the placeholders should have a dynamic
              batch dimension. Otherwise they will be fixed shape.
  
      Returns:
          a Python function that can be called in either mode.
      """
  
      if tf.executing_eagerly():
          assert session_or_none is None
      else:
          assert session_or_none is not None
  
      def make_wrapper(fn):
          # Static-graph mode: Create placeholders and make a session call each
          # time the wrapped function is called. Return this session call's
          # outputs.
          if session_or_none is not None:
              args_placeholders = []
              kwargs_placeholders = {}
              symbolic_out = [None]
  
              def call(*args, **kwargs):
                  args_flat = []
                  for a in args:
                      if type(a) is list:
                          args_flat.extend(a)
                      else:
                          args_flat.append(a)
                  args = args_flat
                  if symbolic_out[0] is None:
                      with session_or_none.graph.as_default():
                          for i, v in enumerate(args):
                              if dynamic_shape:
                                  if len(v.shape) > 0:
                                      shape = (None, ) + v.shape[1:]
                                  else:
                                      shape = ()
                              else:
                                  shape = v.shape
                              args_placeholders.append(
                                  tf1.placeholder(
                                      dtype=v.dtype,
                                      shape=shape,
                                      name="arg_{}".format(i)))
                          for k, v in kwargs.items():
                              if dynamic_shape:
                                  if len(v.shape) > 0:
                                      shape = (None, ) + v.shape[1:]
                                  else:
                                      shape = ()
                              else:
                                  shape = v.shape
                              kwargs_placeholders[k] = \
                                  tf1.placeholder(
                                      dtype=v.dtype,
                                      shape=shape,
                                      name="kwarg_{}".format(k))
                          symbolic_out[0] = fn(*args_placeholders,
                                               **kwargs_placeholders)
                  feed_dict = dict(zip(args_placeholders, args))
                  feed_dict.update(
                      {kwargs_placeholders[k]: kwargs[k]
                       for k in kwargs.keys()})
                  ret = session_or_none.run(symbolic_out[0], feed_dict)
                  return ret
  
              return call
          # Eager mode (call function as is).
          else:
              return fn
  
      return make_wrapper
code_tokens: def make_tf_callable ( session_or_none , dynamic_shape = False ) : if tf . executing_eagerly ( ) : assert session_or_none is None else : assert session_or_none is not None def make_wrapper ( fn ) : if session_or_none is not None : args_placeholders = [ ] kwargs_placeholders = { } symbolic_out = [ None ] def call ( * args , ** kwargs ) : args_flat = [ ] for a in args : if type ( a ) is list : args_flat . extend ( a ) else : args_flat . append ( a ) args = args_flat if symbolic_out [ 0 ] is None : with session_or_none . graph . as_default ( ) : for i , v in enumerate ( args ) : if dynamic_shape : if len ( v . shape ) > 0 : shape = ( None , ) + v . shape [ 1 : ] else : shape = ( ) else : shape = v . shape args_placeholders . append ( tf1 . placeholder ( dtype = v . dtype , shape = shape , name = "arg_{}" . format ( i ) ) ) for k , v in kwargs . items ( ) : if dynamic_shape : if len ( v . shape ) > 0 : shape = ( None , ) + v . shape [ 1 : ] else : shape = ( ) else : shape = v . shape kwargs_placeholders [ k ] = tf1 . placeholder ( dtype = v . dtype , shape = shape , name = "kwarg_{}" . format ( k ) ) symbolic_out [ 0 ] = fn ( * args_placeholders , ** kwargs_placeholders ) feed_dict = dict ( zip ( args_placeholders , args ) ) feed_dict . update ( { kwargs_placeholders [ k ] : kwargs [ k ] for k in kwargs . keys ( ) } ) ret = session_or_none . run ( symbolic_out [ 0 ] , feed_dict ) return ret return call else : return fn return make_wrapper
short_docstring: Returns a function that can be executed in either graph or eager mode.
short_docstring_tokens: Returns a function that can be executed in either graph or eager mode .
comment: """Returns a function that can be executed in either graph or eager mode.
  
      The function must take only positional args.
  
      If eager is enabled, this will act as just a function. Otherwise, it
      will build a function that executes a session run with placeholders
      internally.
  
      Args:
          session_or_none (tf.Session): tf.Session if in graph mode, else None.
          dynamic_shape (bool): True if the placeholders should have a dynamic
              batch dimension. Otherwise they will be fixed shape.
  
      Returns:
          a Python function that can be called in either mode.
      """$SEP$# Static-graph mode: Create placeholders and make a session call each$SEP$# time the wrapped function is called. Return this session call's$SEP$# outputs.$SEP$# Eager mode (call function as is).