def translate(self):
    translation_plan = self.plan.copy()
    translation_plan.forward = None
    args = translation_plan.create_dummy_args()
    translation_plan.validate_input_types = False

    def wrap_stateful_plan(*args):
        role = translation_plan.role
        state = args[(- 1)]
        if ((0 < len(role.state.state_placeholders) == len(state)) and isinstance(state, (list, tuple))):
            state_placeholders = tuple((role.placeholders[ph.id.value] for ph in role.state.state_placeholders))
            PlaceHolder.instantiate_placeholders(role.state.state_placeholders, state)
            PlaceHolder.instantiate_placeholders(state_placeholders, state)
        return translation_plan(*args[:(- 1)])
    plan_params = translation_plan.parameters()
    if (len(plan_params) > 0):
        torchscript_plan = jit.trace(wrap_stateful_plan, (*args, plan_params))
    else:
        torchscript_plan = jit.trace(translation_plan, args)
    self.plan.torchscript = torchscript_plan
    return self.plan
def translate(self):
    translation_plan = self.plan.copy()
    translation_plan.forward = None
    args = translation_plan.create_dummy_args()
    translation_plan.validate_input_types = False

    def wrap_stateful_plan(*args):
        role = translation_plan.role
        state = args[(- 1)]
        if ((0 < len(role.state.state_placeholders) == len(state)) and isinstance(state, (list, tuple))):
            state_placeholders = tuple((role.placeholders[ph.id.value] for ph in role.state.state_placeholders))
            PlaceHolder.instantiate_placeholders(role.state.state_placeholders, state)
            PlaceHolder.instantiate_placeholders(state_placeholders, state)
        return translation_plan(*args[:(- 1)])
    plan_params = translation_plan.parameters()
    if (len(plan_params) > 0):
        torchscript_plan = jit.trace(wrap_stateful_plan, (*args, plan_params))
    else:
        torchscript_plan = jit.trace(translation_plan, args)
    self.plan.torchscript = torchscript_plan
    return self.plan