[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[],null,["# tf.autograph.to_code\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/autograph/impl/api.py#L904-L946) |\n\nReturns the source code generated by AutoGraph, as a string. \n\n tf.autograph.to_code(\n entity, recursive=True, experimental_optional_features=None\n )\n\n### Used in the notebooks\n\n| Used in the guide |\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| - [Better performance with tf.function](https://www.tensorflow.org/guide/function) - [Introduction to graphs and tf.function](https://www.tensorflow.org/guide/intro_to_graphs) |\n\n#### Example usage:\n\n def f(x):\n if x \u003c 0:\n x = -x\n return x\n tf.autograph.to_code(f)\n \"...def tf__f(x):...\"\n\nAlso see: [`tf.autograph.to_graph`](../../tf/autograph/to_graph).\n**Note:** If a function has been decorated with [`tf.function`](../../tf/function), pass its underlying Python function, rather than the callable that \\`tf.function creates: \n\n @tf.function\n def f(x):\n if x \u003c 0:\n x = -x\n return x\n tf.autograph.to_code(f.python_function)\n \"...def tf__f(x):...\"\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------------------|-----------------------------------------------------------------------------------------------------------------------|\n| `entity` | Python callable or class to convert. |\n| `recursive` | Whether to recursively convert any functions that the converted function may call. |\n| `experimental_optional_features` | `None`, a tuple of, or a single [`tf.autograph.experimental.Feature`](../../tf/autograph/experimental/Feature) value. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The converted code as string. ||\n\n\u003cbr /\u003e"]]