code: def _create_function(ctx, network, f, variable_index):
      variable_index_name = "".join(
          [
              "_" + f.repeat_id[index] + "[" + str(i) + "]"
              for index, i in enumerate(variable_index)
          ]
      )
      variable_index_low_level_name = "".join(
          [
              "_" + f.repeat_id[index] + "[" + str(i) + "]"
              for index, i in enumerate(variable_index[:-1])
          ]
      )
      function_name = f.name + variable_index_name
  
      if f.type == "RepeatStart":
          # RepeatStart takes input variable and t-1 variable
          assert len(f.input) == 2
          if variable_index[-1] == 0:
              # Input variable if t == 0
              input_variable_names = [
                  f.input[0]
                  if f.input[0] in network.variables
                  else f.input[0] + variable_index_low_level_name
              ]
          else:
              # t-1 variable if t > 0
              input_variable_names = [
                  f.input[1]
                  + variable_index_low_level_name
                  + "_"
                  + f.repeat_param.repeat_id
                  + "["
                  + str(variable_index[-1] - 1)
                  + "]"
              ]
  
      elif f.type == "RepeatEnd":
          assert len(f.input) == 1
          input_variable_names = [
              f.input[0]
              + variable_index_name
              + "_"
              + f.repeat_param.repeat_id
              + "["
              + str(f.repeat_param.times - 1)
              + "]"
          ]
  
      elif f.type == "RecurrentInput":
          if variable_index[-1] > 0:
              # Create single split function for single RecurrentInput
              return None, None, None
          function_name = f.name + variable_index_low_level_name
          variable_index_name = variable_index_low_level_name
          input_variable_names = [
              v_name
              if v_name in network.variables
              else v_name + variable_index_low_level_name
              for v_name in f.input
          ]
  
      elif f.type == "RecurrentOutput":
          assert len(f.input) == 1
          input_variable_names = [
              f.input[0]
              + variable_index_name
              + "_"
              + f.recurrent_param.repeat_id
              + "["
              + str(v_index)
              + "]"
              for v_index in range(f.recurrent_param.length)
          ]
  
      elif f.type == "Delay":
          # Delay takes t-1 variable and initial value
          assert len(f.input) == 2
          if variable_index[-1] == 0:
              # Initial value if t == 0
              input_variable_names = [
                  f.input[1]
                  if f.input[1] in network.variables
                  else f.input[1] + variable_index_low_level_name
              ]
          else:
              # t-1 variable if t > 0
              input_variable_names = [
                  f.input[0]
                  + variable_index_low_level_name
                  + "_"
                  + f.recurrent_param.repeat_id
                  + "["
                  + str(variable_index[-1] - 1)
                  + "]"
              ]
      else:
          v_names = []
          for v_name in f.input:
              for index, i in enumerate(variable_index):
                  v_name = v_name.replace(
                      "{" + f.repeat_id[index] + "}", "[" + str(i) + "]"
                  )
              v_names.append(v_name)
          input_variable_names = [
              v_name
              if v_name in network.variables
              else v_name + variable_index_name
              if v_name + variable_index_name in network.variables
              else v_name + variable_index_low_level_name
              for v_name in v_names
          ]
      inputs = [
          network.variables[v_name] for v_name in input_variable_names
      ]
  
      if f.type == "RecurrentInput":
          assert len(inputs) == 1
          assert len(f.output) == 1
          output_variable_names = [
              f.output[0]
              + variable_index_low_level_name
              + "_"
              + f.recurrent_param.repeat_id
              + "["
              + str(v_index)
              + "]"
              for v_index in range(
                  inputs[0].shape[f.recurrent_param.axis]
              )
          ]
      else:
          output_variable_names = [
              v_name + variable_index_name
              if v_name + variable_index_name in network.variables
              else v_name
              for v_name in f.output
          ]
  
      outputs = [
          network.variables[v_name] for v_name in output_variable_names
      ]
  
      persistent = True
      if f.type == "Reshape":
          shape = resolve_reshape_params(inputs, f, network.batch_size)
          function_instance = F.Reshape(ctx, shape=shape, inplace=True)
      elif f.type == "RepeatStart":
          function_instance = F.Identity(ctx)
          persistent = False
      elif f.type == "RepeatEnd":
          function_instance = F.Identity(ctx)
          persistent = False
      elif f.type == "RecurrentOutput":
          function_instance = F.Stack(ctx, axis=f.recurrent_param.axis)
      elif f.type == "RecurrentInput":
          function_instance = F.Split(ctx, axis=f.recurrent_param.axis)
      elif f.type == "Delay":
          function_instance = F.Identity(ctx)
          persistent = False
      elif f.type == "Broadcast":
          shape = resolve_broadcast_params(
              inputs, f, network.batch_size
          )
          function_instance = F.Broadcast(ctx, shape)
      else:
          function_instance = _create_function_instance(ctx, f)
  
      # Prepare link structure
      class Function:
          pass
  
      function = Function()
      function.name = function_name
      function.function_instance = function_instance
      function.inputs = list(inputs)
      function.outputs = list(outputs)
      function.persistent = persistent
  
      return function, input_variable_names, output_variable_names
  
imports: from collections import OrderedDict
  import google.protobuf.text_format
  import itertools
  import numpy
  import os
  import re
  import shutil
  import tempfile
  from nnabla.initializer import NormalInitializer, UniformInitializer, ConstantInitializer, RangeInitializer, calc_normal_std_he_forward, calc_normal_std_he_backward, calc_normal_std_glorot, calc_uniform_lim_glorot
  from nnabla.logger import logger
  from nnabla.parameter import get_parameter_or_create
  from nnabla.utils import nnabla_pb2
  from nnabla.utils.data_iterator import data_iterator_csv_dataset, data_iterator_cache
  from nnabla.utils.create_cache import CreateCache
  from nnabla.utils.load_function import _create_function_instance
  from nnabla.utils.nnp_format import nnp_version
  from nnabla.utils.communicator_util import current_communicator, single_or_rankzero
  from nnabla.utils.learning_rate_scheduler import PolynomialScheduler, CosineScheduler, ExponentialScheduler, StepScheduler, LinearWarmupScheduler
  from legacy_network import Network
  from nnabla.utils.progress import progress
  from legacy_get_file_handle import get_file_handle_load, get_buf_type
  import nnabla
  import nnabla.function
  import nnabla.solver
label_desc: Use image node_id 3 for calling a global function with example usage: _create_function(ctx, network, f, variable_index) and returns: function,  input_variable_names,  output_variable_names, None,  None,  None