class_docstr: A helper for constructing the namespace open and close strings for a nested set of namespaces.
  
  e.g. for namespace_str torch::lazy,
  
  prologue:
  namespace torch {
  namespace lazy {
  
  epilogue:
  } // namespace lazy
  } // namespace torch
class_docstr_tok: ["A","helper","for","constructing","the","namespace","open","and","close","strings","for","a","nested","set","of","namespaces",".","e.g",".","for","namespace_str","torch",":",":lazy",",","prologue",":","namespace","torch","{","namespace","lazy","{","epilogue",":","}","\/\/","namespace","lazy","}","\/\/","namespace","torch"]
code: def __init__(
      self,
      namespace_str: str,
      entity_name: str = "",
      max_level: int = 2,
  ):
      # cpp_namespace can be a colon joined string such as torch::lazy
      cpp_namespaces = namespace_str.split("::")
      assert (
          len(cpp_namespaces) <= max_level
      ), f"Codegen doesn't support more than {max_level} level(s) of custom namespace. Got {namespace_str}."
      self.cpp_namespace_ = namespace_str
      self.prologue_ = "\n".join(
          [f"namespace {n} {{" for n in cpp_namespaces]
      )
      self.epilogue_ = "\n".join(
          [f"}} // namespace {n}" for n in reversed(cpp_namespaces)]
      )
      self.namespaces_ = cpp_namespaces
      self.entity_name_ = entity_name
  
imports: import contextlib
  import functools
  import hashlib
  import os
  import re
  import sys
  import textwrap
  from argparse import Namespace
  from dataclasses import fields, is_dataclass
  from enum import auto, Enum
  from typing import Any, Callable, Dict, Generic, Iterable, Iterator, List, Literal, NoReturn, Optional, Sequence, Set, Tuple, TypeVar, Union
  from typing_extensions import Self
  from torchgen.code_template import CodeTemplate
label_desc: Use image node_id 1 to create a new NamespaceHelper object  with example: obj = NamespaceHelper(namespace_str, entity_name, max_level)