You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: embeddings.rs
    path of file: ./repos/rust-bert/src/models/m2m_100
    
    the code of the file until where you have to start completion: // Copyright 2021 The Fairseq Authors and The HuggingFace Inc. team. All rights reserved.
// Copyright 2020 Guillaume Becquin
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//     http://www.apache.org/licenses/LICENSE-2.0
/
    
    pub fn forward(&self, input_ids: &Tensor, past_key_values_length: i64, kind: Kind) -> Tensor {
        let position_ids =
            self.create_position_ids_from_input_ids(input_ids, past_key_values_length);
        let input_size = input_ids.size();
        let seq_length = input_size[1];

        let max_pos = self.padding_idx + 1 + seq_length;
        let current_size = self.embedding.read().unwrap().ws.size()[0];
        if max_pos > current_size {
            self.embedding.write().unwrap().ws.set_data(
                &SinusoidalPositionalEmbedding::build_positional_embeddings(
                    max_pos + self.offset,
                    self.embedding_dim,
                    self.padding_idx,
                    input_ids.device(),
                ),
            );
        }
        let current_kind = self.embedding.read().unwrap().ws.kind();
        if current_kind != kind {
            let new_embeddings = &self.embedding.read().unwrap().ws.to_kind(kind);
            self.embedding.write().unwrap().ws.set_data(new_embeddings);
        }
        position_ids.apply(self.embedding.read().unwrap().deref())
    }