parameters: (
      module_class: Type[tf.Module], exported_names: Sequence[str] = ()
  )
return_statement: return dict(zip(method_names, tflite_modules))
docstring: Compiles a tf.Module's methods with TFLite.
  
    Args:
      module_class: A tf.Module subclass to compile with TFLite.
      exported_names: an optional iterable of strings representing which of the
        module_class's functions should be compiled. If exported_names is empty
        then all functions will be compiled.
  
    Returns:
      A dict mapping method names to compiled TFLite module bytes.
docstring_summary: Compiles a tf.Module's methods with TFLite.
docstring_tokens: Compiles a tf . Module s methods with TFLite .
function: def tf_module_to_tflite_module_bytes(
      module_class: Type[tf.Module], exported_names: Sequence[str] = ()
  ) -> Dict[str, bytes]:
    """Compiles a tf.Module's methods with TFLite.
  
    Args:
      module_class: A tf.Module subclass to compile with TFLite.
      exported_names: an optional iterable of strings representing which of the
        module_class's functions should be compiled. If exported_names is empty
        then all functions will be compiled.
  
    Returns:
      A dict mapping method names to compiled TFLite module bytes.
    """
    tflite_modules = []
    methods, method_names, instance = _get_concrete_functions(
        module_class, exported_names)
    failed_methods = []
    for method, method_name in zip(methods, method_names):
      logging.info("Attempting to convert '%s' to tflite...", method_name)
      try:
        converter = tf.lite.TFLiteConverter.from_concrete_functions([method],
                                                                    module_class)
        logging.info("...converted '%s' to tflite.", method_name)
        tflite_modules.append(converter.convert())
      except Exception as e:
        logging.error("Failed to convert '%s' to tflite.", method_name)
        logging.error("TFLite excpetion: %s", e)
        failed_methods.append(method_name)
  
    if failed_methods:
      raise RuntimeError(
          f"Failed to convert the following methods to tflite: {failed_methods}")
  
    # Keep variables alive until TFLite has done the conversion; ConcreteFunctions
    # themselves only keep weak references to variables.
    del instance
    return dict(zip(method_names, tflite_modules))
function_tokens: def tf_module_to_tflite_module_bytes ( module_class : Type [ tf . Module ] , exported_names : Sequence [ str ] = ( ) ) -> Dict [ str , bytes ] : tflite_modules = [ ] methods , method_names , instance = _get_concrete_functions ( module_class , exported_names ) failed_methods = [ ] for method , method_name in zip ( methods , method_names ) : logging . info ( "Attempting to convert '%s' to tflite..." , method_name ) try : converter = tf . lite . TFLiteConverter . from_concrete_functions ( [ method ] , module_class ) logging . info ( "...converted '%s' to tflite." , method_name ) tflite_modules . append ( converter . convert ( ) ) except Exception as e : logging . error ( "Failed to convert '%s' to tflite." , method_name ) logging . error ( "TFLite excpetion: %s" , e ) failed_methods . append ( method_name ) if failed_methods : raise RuntimeError ( f"Failed to convert the following methods to tflite: {failed_methods}" ) # Keep variables alive until TFLite has done the conversion; ConcreteFunctions # themselves only keep weak references to variables. del instance return dict ( zip ( method_names , tflite_modules ) )