code: def _create_backend(
      name: str,
      component: ComponentFiles,
      directory: Path,
      package_name: str,
  ):
      if component.template in gradio.components.__all__:
          module = "components"
      elif component.template in gradio.layouts.__all__:
          module = "layouts"
      elif component.template in gradio._simple_templates.__all__:  # type: ignore
          module = "_simple_templates"
      else:
          raise ValueError(
              f"Cannot find {component.template} in gradio.components or gradio.layouts. "
              "Please pass in a valid component name via the --template option. "
              "It must match the name of the python class exactly."
          )
  
      readme_contents = textwrap.dedent(
          """
  # {package_name}
  A Custom Gradio component.
  
  ## Example usage
  
  ```python
  import gradio as gr
  from {package_name} import {name}
  ```
  """
      ).format(package_name=package_name, name=name)
      (directory / "README.md").write_text(readme_contents)
  
      backend = directory / "backend" / package_name
      backend.mkdir(exist_ok=True, parents=True)
  
      gitignore = Path(__file__).parent / "files" / "gitignore"
      gitignore_contents = gitignore.read_text()
      gitignore_dest = directory / ".gitignore"
      gitignore_dest.write_text(gitignore_contents)
  
      pyproject = Path(__file__).parent / "files" / "pyproject_.toml"
      pyproject_contents = pyproject.read_text()
      pyproject_dest = directory / "pyproject.toml"
      pyproject_contents = pyproject_contents.replace(
          "<<name>>", package_name
      ).replace(
          "<<template>>", PATTERN.format(template=component.template)
      )
      pyproject_dest.write_text(pyproject_contents)
  
      demo_dir = directory / "demo"
      demo_dir.mkdir(exist_ok=True, parents=True)
  
      (demo_dir / "app.py").write_text(
          f"""
  import gradio as gr
  from {package_name} import {name}
  
  {component.demo_code.format(name=name)}
  
  demo.launch()
  """
      )
      (demo_dir / "__init__.py").touch()
  
      init = backend / "__init__.py"
      init.write_text(
          f"""
  from .{name.lower()} import {name}
  
  __all__ = ['{name}']
  """
      )
  
      p = Path(inspect.getfile(gradio)).parent
      python_file = backend / f"{name.lower()}.py"
  
      shutil.copy(
          str(p / module / component.python_file_name),
          str(python_file),
      )
  
      source_pyi_file = (
          p / module / component.python_file_name.replace(".py", ".pyi")
      )
      pyi_file = backend / f"{name.lower()}.pyi"
      if source_pyi_file.exists():
          shutil.copy(str(source_pyi_file), str(pyi_file))
  
      content = python_file.read_text()
      python_file.write_text(
          _replace_old_class_name(component.template, name, content)
      )
      if pyi_file.exists():
          pyi_content = pyi_file.read_text()
          pyi_file.write_text(
              _replace_old_class_name(
                  component.template, name, pyi_content
              )
          )
  
imports: from __future__ import annotations
  import dataclasses
  import inspect
  import json
  import re
  import shutil
  import textwrap
  from pathlib import Path
  from typing import Literal
  import gradio
label_desc: Use image node_id 8 for calling a global function with example usage: _create_backend(name, component, directory, package_name) without return types