code: def prepare_mbart_inputs_dict(
      config,
      input_ids,
      decoder_input_ids,
      attention_mask=None,
      decoder_attention_mask=None,
      head_mask=None,
      decoder_head_mask=None,
      cross_attn_head_mask=None,
  ):
      if attention_mask is None:
          attention_mask = input_ids.ne(config.pad_token_id)
      if decoder_attention_mask is None:
          decoder_attention_mask = decoder_input_ids.ne(
              config.pad_token_id
          )
      if head_mask is None:
          head_mask = torch.ones(
              config.encoder_layers,
              config.encoder_attention_heads,
              device=torch_device,
          )
      if decoder_head_mask is None:
          decoder_head_mask = torch.ones(
              config.decoder_layers,
              config.decoder_attention_heads,
              device=torch_device,
          )
      if cross_attn_head_mask is None:
          cross_attn_head_mask = torch.ones(
              config.decoder_layers,
              config.decoder_attention_heads,
              device=torch_device,
          )
      return {
          "input_ids": input_ids,
          "decoder_input_ids": decoder_input_ids,
          "attention_mask": attention_mask,
          "decoder_attention_mask": attention_mask,
          "head_mask": head_mask,
          "decoder_head_mask": decoder_head_mask,
          "cross_attn_head_mask": cross_attn_head_mask,
      }
  
imports: import copy
  import tempfile
  import unittest
  from transformers import MBartConfig, is_torch_available
  from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, require_torch_fp16, slow, torch_device
  from transformers.utils import cached_property
  from ...generation.test_utils import GenerationTesterMixin
  from ...test_configuration_common import ConfigTester
  from ...test_modeling_common import ModelTesterMixin, ids_tensor
  from ...test_pipeline_mixin import PipelineTesterMixin
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_mbart_inputs_dict(config, input_ids, decoder_input_ids, attention_mask, decoder_attention_mask, head_mask, decoder_head_mask, cross_attn_head_mask) and returns: dict