code: def nodes_or_number(which_args):
      """Decorator to allow number of nodes or container of nodes.
  
      With this decorator, the specified argument can be either a number or a container
      of nodes. If it is a number, the nodes used are `range(n)`.
      This allows `nx.complete_graph(50)` in place of `nx.complete_graph(list(range(50)))`.
      And it also allows `nx.complete_graph(any_list_of_nodes)`.
  
      Parameters
      ----------
      which_args : string or int or sequence of strings or ints
          If string, the name of the argument to be treated.
          If int, the index of the argument to be treated.
          If more than one node argument is allowed, can be a list of locations.
  
      Returns
      -------
      _nodes_or_numbers : function
          Function which replaces int args with ranges.
  
      Examples
      --------
      Decorate functions like this::
  
         @nodes_or_number("nodes")
         def empty_graph(nodes):
             # nodes is converted to a list of nodes
  
         @nodes_or_number(0)
         def empty_graph(nodes):
             # nodes is converted to a list of nodes
  
         @nodes_or_number(["m1", "m2"])
         def grid_2d_graph(m1, m2, periodic=False):
             # m1 and m2 are each converted to a list of nodes
  
         @nodes_or_number([0, 1])
         def grid_2d_graph(m1, m2, periodic=False):
             # m1 and m2 are each converted to a list of nodes
  
         @nodes_or_number(1)
         def full_rary_tree(r, n)
             # presumably r is a number. It is not handled by this decorator.
             # n is converted to a list of nodes
      """
  
      def _nodes_or_number(n):
          try:
              nodes = list(range(n))
          except TypeError:
              nodes = tuple(n)
          else:
              if n < 0:
                  raise nx.NetworkXError(
                      f"Negative number of nodes not valid: {n}"
                  )
          return (n, nodes)
  
      try:
          iter_wa = iter(which_args)
      except TypeError:
          iter_wa = (which_args,)
  
      return argmap(_nodes_or_number, *iter_wa)
  
imports: import bz2
  import collections
  import gzip
  import inspect
  import itertools
  import re
  import warnings
  from collections import defaultdict
  from contextlib import contextmanager
  from functools import wraps
  from inspect import Parameter, signature
  from os.path import splitext
  from pathlib import Path
  import networkx
  from networkx.utils import create_py_random_state, create_random_state
label_desc: Use image node_id 3 for calling a global function with example usage: nodes_or_number(which_args) and returns: argmap, n,  nodes