code: def _add_resource_to_set(resource_set, resource, include_rg=True):
      rg: Optional[_resource.ResourceGroup]
      if isinstance(resource, _resource.ResourceGroup):
          rg = resource
          if include_rg:
              resource_set.add(resource)
      else:
          resource_set.add(resource)
          if (
              isinstance(resource, _resource.ResourceFile)
              and resource._has_resource_group()
          ):
              rg = resource._get_resource_group()
          else:
              rg = None
  
      if rg is not None:
          for _, resource_file in rg._resources.items():
              resource_set.add(resource_file)
  
imports: import asyncio
  import inspect
  import os
  import re
  import textwrap
  import warnings
  from shlex import quote
  from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union, cast, Literal
  from typing_extensions import Self
  import hailtop.batch_client.client
  from .None import backend, batch
  from .None import resource
  from .exceptions import BatchException
label_desc: Use image node_id 1 for calling a global function with example usage: _add_resource_to_set(resource_set, resource, include_rg) without return types