code: def generate_proto(source, require=True):
      """Invokes the Protocol Compiler to generate a _pb2.py."""
  
      # Does nothing if the output already exists and is newer than
      # the input.
  
      if not require and not os.path.exists(source):
          return
  
      output = source.replace(".proto", "_pb2.py").replace(
          "../src/", ""
      )
  
      if not os.path.exists(output) or (
          os.path.exists(source)
          and os.path.getmtime(source) > os.path.getmtime(output)
      ):
          print("Generating %s..." % output)
  
          if not os.path.exists(source):
              sys.stderr.write(
                  "Can't find required file: %s\n" % source
              )
              sys.exit(-1)
  
          if protoc is None:
              sys.stderr.write(
                  "protoc is not installed nor found in ../src.  Please compile it "
                  "or install the binary package.\n"
              )
              sys.exit(-1)
  
          protoc_command = [
              protoc,
              "-I../src",
              "-I.",
              "--python_out=.",
              source,
          ]
          if subprocess.call(protoc_command) != 0:
              sys.exit(-1)
  
imports: from distutils import log
  from distutils import spawn
  import os
  import platform
  import subprocess
  import sys
  from setuptools import Command
  from setuptools import find_packages
  from setuptools import setup
  from setuptools.command.build_py import build_py
  from setuptools.command.develop import develop
  from setuptools.command.egg_info import egg_info
  from setuptools.command.sdist import sdist
label_desc: Use image node_id 1 for calling a global function with example usage: generate_proto(source, require) without return types