code: def collect_function_arg_names(
      function_names, return_all_args_function_names, function_renames
  ):
      """Determines argument names for reordered function signatures.
  
      Args:
        function_names: Functions to collect arguments for.
        return_all_args_function_names: Functions to collect all argument names for.
        function_renames: Function renames between v1 and v2.
  
      Returns:
        Dictionary mapping function names to a list of argument names. Each argument
        name list can have leading `None` elements to indicate that some of the
        function arguments did not change between v1 and v2.
      """
      function_name_v1_to_attr = {}
      function_name_v2_to_attr = {}
  
      def visit(unused_path, unused_parent, children):
          """Visitor that collects arguments for reordered functions."""
          for child in children:
              _, attr = tf_decorator.unwrap(child[1])
  
              api_names_v1 = [
                  "tf." + name for name in tf_export.get_v1_names(attr)
              ]
              if any(name in function_names for name in api_names_v1):
                  for name in api_names_v1:
                      function_name_v1_to_attr[name] = attr
  
              api_names_v2 = [
                  "tf." + name for name in tf_export.get_v2_names(attr)
              ]
              for name in api_names_v2:
                  function_name_v2_to_attr[name] = attr
  
      visitor = public_api.PublicAPIVisitor(visit)
      visitor.do_not_descend_map["tf"].append("contrib")
      visitor.private_map["tf.compat"] = ["v1", "v2"]
      traverse.traverse(tf.compat.v1, visitor)
      traverse.traverse(tf.compat.v1.estimator, visitor)
      traverse.traverse(tf.compat.v2, visitor)
      traverse.traverse(tf.compat.v2.estimator, visitor)
  
      def get_arguments_list(attr):
          if tf_inspect.isclass(attr):
              # Get constructor arguments if attr is a class
              arg_list = tf_inspect.getargspec(
                  getattr(attr, "__init__")
              )[0]
              return arg_list[1:]  # skip 'self' argument
          else:
              # Get function arguments.
              # getargspec returns a tuple of (args, varargs, keywords, defaults)
              # we just look at args.
              return tf_inspect.getargspec(attr)[0]
  
      # Map from reordered function name to its arguments.
      function_to_args = {}
  
      if any(
          name not in function_name_v1_to_attr
          for name in function_names
      ):
          raise ValueError(
              "Symbols not found in `tf.compat.v1`: "
              f'`{"`, `".join(function_names - function_name_v1_to_attr.keys())}`'
          )
  
      for name_v1, attr_v1 in function_name_v1_to_attr.items():
          args_v1 = get_arguments_list(attr_v1)
  
          # Per `return_all_args_function_names override`, return all argument names
          # without comparing with v2.
          if name_v1 in return_all_args_function_names:
              function_to_args[name_v1] = args_v1
              continue
  
          name_v2 = name_v1
          if name_v1 in function_renames:
              name_v2 = function_renames[name_v1]
              # If the rename is simply mapping `tf.x` to `tf.compat.v1.x`, there is no
              # change in the arguments, we shouldn't have it in the list.
              if name_v2.startswith("tf.compat.v1."):
                  raise ValueError(
                      f"Symbol `{name_v1}` is renamed to `{name_v2}`, "
                      "no need to add keyword argument names, "
                      "remove from `reordered_function_names`"
                  )
  
          if name_v2 not in function_name_v2_to_attr:
              raise ValueError(
                  f"Symbol `{name_v2}` not found in `tf.compat.v2`"
              )
          args_v2 = get_arguments_list(
              function_name_v2_to_attr[name_v2]
          )
  
          # If there is no change in the arguments, we shouldn't have it in the list.
          if args_v1 == args_v2:
              raise ValueError(
                  f"Symbol `{name_v1}` has no changes in arguments, "
                  "no need to add keyword argument names, "
                  "remove from `reordered_function_names`"
              )
  
          # Compare v1/v2 argument names and put `None` as long as they're identical.
          needed_arg_names = []
          same_so_far = True
          for index, arg in enumerate(args_v1):
              if (
                  same_so_far
                  and index < len(args_v2)
                  and arg == args_v2[index]
              ):
                  needed_arg_names.append(None)
              else:
                  same_so_far = False
                  needed_arg_names.append(arg)
          function_to_args[name_v1] = needed_arg_names
  
      return function_to_args
  
file_path: tensorflow-upstream/tensorflow/tools/compatibility/update/generate_v2_reorders_map.py
imports: from absl import app
  import tensorflow
  from tensorflow import python
  from tensorflow.python.lib.io import file_io
  from tensorflow.python.util import tf_decorator
  from tensorflow.python.util import tf_export
  from tensorflow.python.util import tf_inspect
  from tensorflow.tools.common import public_api
  from tensorflow.tools.common import traverse
  from tensorflow.tools.compatibility import tf_upgrade_v2
label_desc: Use image node_id 1 for calling a global function with example usage: collect_function_arg_names(function_names, return_all_args_function_names, function_renames) and returns: function_to_args, arg_list, tf_inspect