code: def write_with_template(
      self,
      filename: str,
      template_fn: str,
      env_callable: Callable[[], Union[str, Dict[str, Any]]],
  ) -> None:
      filename = f"{self.install_dir}/{filename}"
      assert (
          filename not in self.filenames
      ), "duplicate file write {filename}"
      self.filenames.add(filename)
      if not self.dry_run:
          substitute_out = self.substitute_with_template(
              template_fn=template_fn,
              env_callable=env_callable,
          )
          self._write_if_changed(
              filename=filename, contents=substitute_out
          )
  
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 4 for calling the FileManager obj's underlying member method code with example usage: obj.write_with_template(filename, template_fn, env_callable) without return types