# tf.compat.v1.keras.backend.name_scope

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/framework/ops.py#L6298-L6346) |

A context manager for use when defining a Python op.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.name_scope`](https://www.tensorflow.org/api_docs/python/tf/compat/v1/name_scope)

<br />

    tf.compat.v1.keras.backend.name_scope(
        name, default_name=None, values=None
    )

This context manager validates that the given `values` are from the
same graph, makes that graph the default graph, and pushes a
name scope in that graph (see
[`tf.Graph.name_scope`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/Graph#name_scope)
for more details on that).

For example, to define a new Python op called `my_op`:

    def my_op(a, b, c, name=None):
      with tf.name_scope(name, "MyOp", [a, b, c]) as scope:
        a = tf.convert_to_tensor(a, name="a")
        b = tf.convert_to_tensor(b, name="b")
        c = tf.convert_to_tensor(c, name="c")
        # Define some computation that uses `a`, `b`, and `c`.
        return foo_op(..., name=scope)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `name` | The name argument that is passed to the op function. |
| `default_name` | The default name to use if the `name` argument is `None`. |
| `values` | The list of `Tensor` arguments that are passed to the op function. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | if `default_name` is passed in but not a string. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `name` | <br /> <br /> |

<br />

## Methods

### `__enter__`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/framework/ops.py#L6342-L6343)

    __enter__()

### `__exit__`

[View source](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/framework/ops.py#L6345-L6346)

    __exit__(
        *exc_info
    )